Class: Riml::ForNode

Inherits:
Struct
  • Object
show all
Includes:
Indentable, Visitable
Defined in:
lib/riml/nodes.rb

Overview

for variable in someFunction(1,2,3)

echo variable

end

OR

for variable in [1,2,3]

echo variable

end

Constant Summary

Constants included from Visitable

Visitable::EMPTY_CHILDREN

Instance Attribute Summary collapse

Attributes included from Visitable

#compiled_output, #force_newline, #parent_node, #parser_info, #scope

Instance Method Summary collapse

Methods included from Indentable

#indent, #indented?, #outdent

Methods included from Visitable

#accept, #force_newline_if_child_call_node?, #location_info

Methods included from Walkable

#child_after, #child_previous_to, #each, #index_by_children, #index_by_member, #insert_after, #insert_before, #next, #previous, #remove, #replace_with

Instance Attribute Details

#expressionsObject

Returns the value of attribute expressions

Returns:

  • (Object)

    the current value of expressions



858
859
860
# File 'lib/riml/nodes.rb', line 858

def expressions
  @expressions
end

#in_expressionObject

Returns the value of attribute in_expression

Returns:

  • (Object)

    the current value of in_expression



858
859
860
# File 'lib/riml/nodes.rb', line 858

def in_expression
  @in_expression
end

#variableObject Also known as: for_variable

Returns the value of attribute variable

Returns:

  • (Object)

    the current value of variable



858
859
860
# File 'lib/riml/nodes.rb', line 858

def variable
  @variable
end

Instance Method Details

#childrenObject



884
885
886
# File 'lib/riml/nodes.rb', line 884

def children
  [variable, in_expression, expressions]
end

#for_node_variable_namesObject



868
869
870
871
872
873
874
# File 'lib/riml/nodes.rb', line 868

def for_node_variable_names
  if ListNode === variable
    variable.value.map(&:name)
  else
    [variable.name]
  end
end

#to_scopeObject



876
877
878
879
880
881
882
# File 'lib/riml/nodes.rb', line 876

def to_scope
  ScopeNode.new.tap do |s|
    s.for_node_variable_names += for_node_variable_names
    s.argument_variable_names = (self.scope && self.scope.argument_variable_names)
    s.function = (self.scope && self.scope.function) || nil
  end
end

#variablesObject



864
865
866
# File 'lib/riml/nodes.rb', line 864

def variables
  variable if ListNode === variable
end