Class: Rjq::AST::Label

Inherits:
Node
  • Object
show all
Defined in:
lib/rjq/ast.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#source_span

Instance Method Summary collapse

Methods inherited from Node

#assign_value, #invalid_path_message, #paths, #take, #with_source_span

Constructor Details

#initialize(label, body) ⇒ Label

Returns a new instance of Label.



756
757
758
759
# File 'lib/rjq/ast.rb', line 756

def initialize(label, body)
  @label = label
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



754
755
756
# File 'lib/rjq/ast.rb', line 754

def body
  @body
end

#labelObject (readonly)

Returns the value of attribute label.



754
755
756
# File 'lib/rjq/ast.rb', line 754

def label
  @label
end

Instance Method Details

#eval(input, context) ⇒ Object



761
762
763
764
765
766
767
768
769
# File 'lib/rjq/ast.rb', line 761

def eval(input, context)
  @body.eval(input, context)
rescue BreakSignal => e
  raise unless e.label == @label

  return e.outputs if e.outputs

  e.value.nil? ? [] : [e.value]
end