Class: Twostroke::AST::Body

Inherits:
Base
  • Object
show all
Defined in:
lib/twostroke/ast/body.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#line

Instance Method Summary collapse

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

#statementsObject

Returns the value of attribute statements.



3
4
5
# File 'lib/twostroke/ast/body.rb', line 3

def statements
  @statements
end

Instance Method Details

#collapseObject



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