Class: Kumi::Core::NAST::Select

Inherits:
Node
  • Object
show all
Defined in:
lib/kumi/core/nast.rb

Overview

Control: ternary select (pure, eager)

Instance Attribute Summary collapse

Attributes inherited from Node

#id, #loc, #meta

Instance Method Summary collapse

Methods inherited from Node

#each_child

Constructor Details

#initialize(cond:, on_true:, on_false:, **k) ⇒ Select

Returns a new instance of Select.



178
179
180
181
182
183
# File 'lib/kumi/core/nast.rb', line 178

def initialize(cond:, on_true:, on_false:, **k)
  super(**k)
  @cond = cond
  @on_true = on_true
  @on_false = on_false
end

Instance Attribute Details

#condObject (readonly)

Returns the value of attribute cond.



176
177
178
# File 'lib/kumi/core/nast.rb', line 176

def cond
  @cond
end

#on_falseObject (readonly)

Returns the value of attribute on_false.



176
177
178
# File 'lib/kumi/core/nast.rb', line 176

def on_false
  @on_false
end

#on_trueObject (readonly)

Returns the value of attribute on_true.



176
177
178
# File 'lib/kumi/core/nast.rb', line 176

def on_true
  @on_true
end

Instance Method Details

#accept(visitor) ⇒ Object



185
186
187
# File 'lib/kumi/core/nast.rb', line 185

def accept(visitor)
  visitor.respond_to?(:visit_select) ? visitor.visit_select(self) : super
end

#childrenObject



189
# File 'lib/kumi/core/nast.rb', line 189

def children = [cond, on_true, on_false]