Class: Cadenza::FilteredValueNode
- Inherits:
-
Object
- Object
- Cadenza::FilteredValueNode
- Defined in:
- lib/cadenza/nodes/filtered_value_node.rb
Overview
The FilteredValueNode applies a list of passed FilterNode to it’s value when evaluated.
Instance Attribute Summary collapse
-
#filters ⇒ Array
A list of FilterNode to evaluate the value with, once the value has itself been evaluated.
-
#value ⇒ Node
The value to be filtered.
Instance Method Summary collapse
-
#==(rhs) ⇒ Boolean
If the given FilteredValueNode is equivalent by value to this node.
-
#eval(context) ⇒ Object
Gets the value and returns it after being passed through all filters.
-
#implied_globals ⇒ Array
A list of names which are implied to be global variables from this node.
-
#initialize(value, filters = []) ⇒ FilteredValueNode
constructor
creates a new FilteredValueNode.
Constructor Details
#initialize(value, filters = []) ⇒ FilteredValueNode
creates a new Cadenza::FilteredValueNode.
16 17 18 19 |
# File 'lib/cadenza/nodes/filtered_value_node.rb', line 16 def initialize(value, filters=[]) @value = value @filters = filters end |
Instance Attribute Details
#filters ⇒ Array
Returns a list of Cadenza::FilterNode to evaluate the value with, once the value has itself been evaluated.
11 12 13 |
# File 'lib/cadenza/nodes/filtered_value_node.rb', line 11 def filters @filters end |
#value ⇒ Node
Returns the value to be filtered.
7 8 9 |
# File 'lib/cadenza/nodes/filtered_value_node.rb', line 7 def value @value end |
Instance Method Details
#==(rhs) ⇒ Boolean
Returns if the given Cadenza::FilteredValueNode is equivalent by value to this node.
41 42 43 |
# File 'lib/cadenza/nodes/filtered_value_node.rb', line 41 def ==(rhs) self.value == rhs.value && self.filters == rhs.filters end |
#eval(context) ⇒ Object
Returns gets the value and returns it after being passed through all filters.
30 31 32 33 34 35 36 |
# File 'lib/cadenza/nodes/filtered_value_node.rb', line 30 def eval(context) value = @value.eval(context) @filters.each {|filter| value = filter.evaluate(context, value) } value end |
#implied_globals ⇒ Array
Returns a list of names which are implied to be global variables from this node.
23 24 25 |
# File 'lib/cadenza/nodes/filtered_value_node.rb', line 23 def implied_globals (@value.implied_globals + @filters.map(&:implied_globals).flatten).uniq end |