Class: Atomy::Grammar::AST::Number

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) ⇒ Number

Returns a new instance of Number.



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

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



112
113
114
# File 'lib/atomy/grammar.rb', line 112

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



14
15
16
# File 'lib/atomy/node/equality.rb', line 14

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

#construct(gen) ⇒ Object



32
33
34
35
36
# File 'lib/atomy/node/constructable.rb', line 32

def construct(gen)
  push_node(gen, :Number)
  gen.push_int(@value)
  gen.send(:new, 1)
end

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

Yields:



63
64
65
# File 'lib/atomy/node/meta.rb', line 63

def each_attribute
  yield :value, @value
end

#to_sObject



11
12
13
# File 'lib/atomy/node/pretty.rb', line 11

def to_s
  @value.to_s
end