Class: Atomy::Grammar::AST::StringLiteral

Inherits:
Node show all
Defined in:
lib/atomy/grammar.rb,
lib/atomy/node/meta.rb,
lib/atomy/node/pretty.rb,
lib/atomy/node/equality.rb,
lib/atomy/node/constructable.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#accept, #attributes, basename, #children, #each_child, #through

Constructor Details

#initialize(value) ⇒ StringLiteral

Returns a new instance of StringLiteral.



149
150
151
# File 'lib/atomy/grammar.rb', line 149

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



152
153
154
# File 'lib/atomy/grammar.rb', line 152

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



109
110
111
# File 'lib/atomy/node/equality.rb', line 109

def ==(other)
  super || other.is_a?(self.class) && @value == other.value
end

#construct(gen) ⇒ Object



163
164
165
166
167
# File 'lib/atomy/node/constructable.rb', line 163

def construct(gen)
  push_node(gen, :StringLiteral)
  gen.push_literal(@value)
  gen.send(:new, 1)
end

#each_attribute {|:value, @value| ... } ⇒ Object

Yields:



202
203
204
# File 'lib/atomy/node/meta.rb', line 202

def each_attribute
  yield :value, @value
end

#to_sObject



104
105
106
# File 'lib/atomy/node/pretty.rb', line 104

def to_s
  @value.inspect
end