Class: RubyJsonParser::AST::StringLiteralNode

Inherits:
Node
  • Object
show all
Defined in:
lib/ruby_json_parser/ast.rb

Overview

Represents a string literal eg. ‘“foo”`

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ StringLiteralNode

Returns a new instance of StringLiteralNode.



144
145
146
# File 'lib/ruby_json_parser/ast.rb', line 144

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



141
142
143
# File 'lib/ruby_json_parser/ast.rb', line 141

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



149
150
151
152
153
# File 'lib/ruby_json_parser/ast.rb', line 149

def ==(other)
  return false unless other.is_a?(StringLiteralNode)

  value == other.value
end

#inspect(indent = 0) ⇒ Object



161
162
163
# File 'lib/ruby_json_parser/ast.rb', line 161

def inspect(indent = 0)
  "#{INDENT_UNIT * indent}#{value.inspect}"
end

#to_sObject



156
157
158
# File 'lib/ruby_json_parser/ast.rb', line 156

def to_s
  value.inspect
end