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