Class: Twostroke::AST::Body
Instance Attribute Summary collapse
-
#statements ⇒ Object
Returns the value of attribute statements.
Attributes inherited from Base
Instance Method Summary collapse
- #collapse ⇒ Object
-
#initialize(*args) ⇒ Body
constructor
A new instance of Body.
- #walk(&bk) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Body
Returns a new instance of Body.
5 6 7 8 |
# File 'lib/twostroke/ast/body.rb', line 5 def initialize(*args) @statements = [] super *args end |
Instance Attribute Details
#statements ⇒ Object
Returns the value of attribute statements.
3 4 5 |
# File 'lib/twostroke/ast/body.rb', line 3 def statements @statements end |
Instance Method Details
#collapse ⇒ Object
10 11 12 |
# File 'lib/twostroke/ast/body.rb', line 10 def collapse self.class.new statements: statements.reject(&:nil?).map(&:collapse) end |
#walk(&bk) ⇒ Object
14 15 16 17 18 |
# File 'lib/twostroke/ast/body.rb', line 14 def walk(&bk) if yield self statements.each { |s| s.walk &bk } end end |