Class: Cadenza::ConstantNode

Inherits:
Object
  • Object
show all
Defined in:
lib/cadenza/nodes/constant_node.rb

Overview

The ConstantNode holds a value which is not affected by any context given to it, such as numbers or strings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ ConstantNode

constructs a new Cadenza::ConstantNode with the given value.



10
11
12
# File 'lib/cadenza/nodes/constant_node.rb', line 10

def initialize(value)
   @value = value
end

Instance Attribute Details

#valueObject



6
7
8
# File 'lib/cadenza/nodes/constant_node.rb', line 6

def value
  @value
end

Instance Method Details

#==(rhs) ⇒ Boolean



27
28
29
# File 'lib/cadenza/nodes/constant_node.rb', line 27

def ==(rhs)
   @value == rhs.value
end

#eval(context) ⇒ Object



21
22
23
# File 'lib/cadenza/nodes/constant_node.rb', line 21

def eval(context)
   @value
end

#implied_globalsArray



15
16
17
# File 'lib/cadenza/nodes/constant_node.rb', line 15

def implied_globals
   []
end