Class: Twostroke::AST::Ternary

Inherits:
Base
  • Object
show all
Defined in:
lib/twostroke/ast/ternary.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

#conditionObject

Returns the value of attribute condition.



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

def condition
  @condition
end

#if_falseObject

Returns the value of attribute if_false.



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

def if_false
  @if_false
end

#if_trueObject

Returns the value of attribute if_true.



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

def if_true
  @if_true
end

Instance Method Details

#collapseObject



5
6
7
# File 'lib/twostroke/ast/ternary.rb', line 5

def collapse
  self.class.new condition: condition.collapse, if_true: if_true.collapse, if_false: if_false.collapse
end

#walk(&bk) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/twostroke/ast/ternary.rb', line 9

def walk(&bk)
  if yield self
    condition.walk &bk
    if_true.walk &bk
    if_false.walk &bk
  end
end