Class: Postsvg::Model::Operators::ControlFlow::Ifelse

Inherits:
Postsvg::Model::Operator show all
Defined in:
lib/postsvg/model/operators/control_flow.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Postsvg::Model::Operator

#accept, #operator?, register_as

Constructor Details

#initialize(condition:, if_body:, else_body:) ⇒ Ifelse

Returns a new instance of Ifelse.



25
26
27
28
29
30
# File 'lib/postsvg/model/operators/control_flow.rb', line 25

def initialize(condition:, if_body:, else_body:)
  @condition = condition
  @if_body = if_body
  @else_body = else_body
  freeze
end

Instance Attribute Details

#conditionObject (readonly)

Returns the value of attribute condition.



24
25
26
# File 'lib/postsvg/model/operators/control_flow.rb', line 24

def condition
  @condition
end

#else_bodyObject (readonly)

Returns the value of attribute else_body.



24
25
26
# File 'lib/postsvg/model/operators/control_flow.rb', line 24

def else_body
  @else_body
end

#if_bodyObject (readonly)

Returns the value of attribute if_body.



24
25
26
# File 'lib/postsvg/model/operators/control_flow.rb', line 24

def if_body
  @if_body
end

Class Method Details

.from_operands(stack) ⇒ Object



31
32
33
34
35
36
# File 'lib/postsvg/model/operators/control_flow.rb', line 31

def self.from_operands(stack)
  else_body = stack.pop
  if_body = stack.pop
  condition = stack.pop
  new(condition: condition, if_body: if_body, else_body: else_body)
end