Class: Riml::ForNode

Inherits:
Struct
  • Object
show all
Includes:
Indentable, Visitable, Walkable
Defined in:
lib/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::DESCENDANT_OF_REGEX

Instance Attribute Summary collapse

Attributes included from Visitable

#compiled_output, #force_newline, #parent_node, #scope

Instance Method Summary collapse

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

Methods included from Indentable

#indent, #indented?, #outdent

Methods included from Visitable

#accept, #method_missing, #respond_to?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Riml::Visitable

Instance Attribute Details

#expressionsObject

Returns the value of attribute expressions

Returns:

  • (Object)

    the current value of expressions



846
847
848
# File 'lib/nodes.rb', line 846

def expressions
  @expressions
end

#in_expressionObject

Returns the value of attribute in_expression

Returns:

  • (Object)

    the current value of in_expression



846
847
848
# File 'lib/nodes.rb', line 846

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



846
847
848
# File 'lib/nodes.rb', line 846

def variable
  @variable
end

Instance Method Details

#childrenObject



869
870
871
# File 'lib/nodes.rb', line 869

def children
  [variable, in_expression, expressions]
end

#for_node_variable_namesObject



857
858
859
860
861
862
863
# File 'lib/nodes.rb', line 857

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

#to_scopeObject



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

def to_scope
  ScopeNode.new.tap {|s| s.for_node_variable_names += for_node_variable_names}
end

#variablesObject



853
854
855
# File 'lib/nodes.rb', line 853

def variables
  variable if ListNode === variable
end