Class: Rjq::AST::Comma
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Attributes inherited from Node
Instance Method Summary collapse
- #eval(input, context) ⇒ Object
-
#initialize(left, right) ⇒ Comma
constructor
A new instance of Comma.
- #paths(input, context) ⇒ Object
- #take(input, context, count) ⇒ Object
Methods inherited from Node
#assign_value, #invalid_path_message, #with_source_span
Constructor Details
#initialize(left, right) ⇒ Comma
Returns a new instance of Comma.
333 334 335 336 |
# File 'lib/rjq/ast.rb', line 333 def initialize(left, right) @left = left @right = right end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
331 332 333 |
# File 'lib/rjq/ast.rb', line 331 def left @left end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
331 332 333 |
# File 'lib/rjq/ast.rb', line 331 def right @right end |
Instance Method Details
#eval(input, context) ⇒ Object
338 339 340 341 342 343 344 345 |
# File 'lib/rjq/ast.rb', line 338 def eval(input, context) left_values = @left.eval(input, context) left_values + @right.eval(input, context) rescue ErrorValue => e raise ErrorValue.new(e.value, outputs: Array(left_values) + (e.outputs || [])) rescue BreakSignal => e raise BreakSignal.new(e.label, e.value, outputs: Array(left_values) + (e.outputs || [])) end |
#paths(input, context) ⇒ Object
354 355 356 |
# File 'lib/rjq/ast.rb', line 354 def paths(input, context) @left.paths(input, context) + @right.paths(input, context) end |
#take(input, context, count) ⇒ Object
347 348 349 350 351 352 |
# File 'lib/rjq/ast.rb', line 347 def take(input, context, count) left_values = @left.take(input, context, count) return left_values if left_values.length >= count left_values + @right.take(input, context, count - left_values.length) end |