Class: Riml::ControlStructure

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

Overview

abstract control structure

Direct Known Subclasses

ElseifNode, IfNode, UntilNode, WhileNode

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

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



756
757
758
# File 'lib/nodes.rb', line 756

def body
  @body
end

#conditionObject

Returns the value of attribute condition

Returns:

  • (Object)

    the current value of condition



756
757
758
# File 'lib/nodes.rb', line 756

def condition
  @condition
end

Instance Method Details

#childrenObject



761
762
763
# File 'lib/nodes.rb', line 761

def children
  [condition, body]
end

#wrap_condition_in_parens!Object



765
766
767
768
769
770
# File 'lib/nodes.rb', line 765

def wrap_condition_in_parens!
  return if WrapInParensNode === condition
  _parent = condition.parent
  self.condition = WrapInParensNode.new(condition)
  self.condition.parent = _parent
end