Class: Cadenza::ConstantNode
- Inherits:
-
Object
- Object
- Cadenza::ConstantNode
- 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
-
#value ⇒ Object
The value of this node.
Instance Method Summary collapse
-
#==(rhs) ⇒ Boolean
If this node and the given one are equivalent by value.
-
#eval(context) ⇒ Object
The value of this node evaluated in the given context.
-
#implied_globals ⇒ Array
Any global variable applied to this node (none).
-
#initialize(value) ⇒ ConstantNode
constructor
constructs a new ConstantNode with the given value.
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
#value ⇒ Object
Returns the value of this node.
6 7 8 |
# File 'lib/cadenza/nodes/constant_node.rb', line 6 def value @value end |
Instance Method Details
#==(rhs) ⇒ Boolean
Returns if this node and the given one are equivalent by value.
27 28 29 |
# File 'lib/cadenza/nodes/constant_node.rb', line 27 def ==(rhs) @value == rhs.value end |
#eval(context) ⇒ Object
Returns the value of this node evaluated in the given context.
21 22 23 |
# File 'lib/cadenza/nodes/constant_node.rb', line 21 def eval(context) @value end |
#implied_globals ⇒ Array
Returns any global variable applied to this node (none).
15 16 17 |
# File 'lib/cadenza/nodes/constant_node.rb', line 15 def implied_globals [] end |