Class: Twostroke::AST::Try

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Twostroke::AST::Base

Instance Attribute Details

#catch_statementsObject

Returns the value of attribute catch_statements.



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

def catch_statements
  @catch_statements
end

#catch_variableObject

Returns the value of attribute catch_variable.



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

def catch_variable
  @catch_variable
end

#finally_statementsObject

Returns the value of attribute finally_statements.



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

def finally_statements
  @finally_statements
end

#try_statementsObject

Returns the value of attribute try_statements.



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

def try_statements
  @try_statements
end

Instance Method Details

#collapseObject



5
6
7
8
9
# File 'lib/twostroke/ast/try.rb', line 5

def collapse
  self.class.new try_statements: try_statements.map(&:collapse), catch_variable: catch_variable,
    catch_statements: (catch_statements && catch_statements.map(&:collapse)),
    finally_statements: (finally_statements && finally_statements.map(&:collapse))
end

#walk(&bk) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/twostroke/ast/try.rb', line 11

def walk(&bk)
  if yield self
    try_statements.each { |s| s.walk &bk }
    catch_statements.each { |s| s.walk &bk } if catch_statements
    finally_statements.each { |s| s.walk &bk } if finally_statements
  end
end