Class: Twostroke::AST::ForLoop
- Defined in:
- lib/twostroke/ast/for_loop.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#condition ⇒ Object
Returns the value of attribute condition.
-
#increment ⇒ Object
Returns the value of attribute increment.
-
#initializer ⇒ Object
Returns the value of attribute initializer.
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Twostroke::AST::Base
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
3 4 5 |
# File 'lib/twostroke/ast/for_loop.rb', line 3 def body @body end |
#condition ⇒ Object
Returns the value of attribute condition.
3 4 5 |
# File 'lib/twostroke/ast/for_loop.rb', line 3 def condition @condition end |
#increment ⇒ Object
Returns the value of attribute increment.
3 4 5 |
# File 'lib/twostroke/ast/for_loop.rb', line 3 def increment @increment end |
#initializer ⇒ Object
Returns the value of attribute initializer.
3 4 5 |
# File 'lib/twostroke/ast/for_loop.rb', line 3 def initializer @initializer end |
Instance Method Details
#collapse ⇒ Object
5 6 7 8 9 10 |
# File 'lib/twostroke/ast/for_loop.rb', line 5 def collapse self.class.new initializer: initializer && initializer.collapse, condition: condition && condition.collapse, increment: increment && increment.collapse, body: body && body.collapse end |
#walk(&bk) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/twostroke/ast/for_loop.rb', line 12 def walk(&bk) if yield self initializer.walk(&bk) if initializer condition.walk(&bk) if condition increment.walk(&bk) if increment body.walk &bk if body end end |