Class: Optimus::ParsedCalculator::ColumnReference
- Defined in:
- lib/expression_parser/expressions.rb
Constant Summary
Constants inherited from Expr
Instance Method Summary collapse
- #evaluate(*args) ⇒ Object
-
#initialize(name) ⇒ ColumnReference
constructor
A new instance of ColumnReference.
- #to_s ⇒ Object
Methods inherited from Expr
#-@, #eq, #logical_and, #logical_not, #logical_or, #neq, #to_bool
Constructor Details
#initialize(name) ⇒ ColumnReference
Returns a new instance of ColumnReference.
132 133 134 |
# File 'lib/expression_parser/expressions.rb', line 132 def initialize(name) @name = name end |
Instance Method Details
#evaluate(*args) ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/expression_parser/expressions.rb', line 140 def evaluate(*args) = args.last || {} row = [:row] || {} computed_columns = [:computed_columns] || {} seen_columns = [:seen_columns] || [] if seen_columns.include?(@name) raise EvaluationLoopError.new( "Loop error - #{@name} depends on itself: [#{seen_columns.join(', ')}]" ) end if !row[@name] and computed_columns.include?(@name) row[@name] = computed_columns[@name].evaluate( :row => row, :computed_columns => computed_columns, :seen_columns => ([@name] + seen_columns) ) end return magic_cast(row[@name]) end |
#to_s ⇒ Object
136 137 138 |
# File 'lib/expression_parser/expressions.rb', line 136 def to_s "{#{@name}}" end |