Class: Postscript::Model::Operators::ControlFlow::If

Inherits:
Postscript::Model::Operator show all
Defined in:
lib/postscript/model/operators/control_flow.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Postscript::Model::Operator

#accept, #operator?, register_as

Constructor Details

#initialize(condition:, body:) ⇒ If

Returns a new instance of If.



10
11
12
13
14
# File 'lib/postscript/model/operators/control_flow.rb', line 10

def initialize(condition:, body:)
  @condition = condition
  @body = body
  freeze
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



9
10
11
# File 'lib/postscript/model/operators/control_flow.rb', line 9

def body
  @body
end

#conditionObject (readonly)

Returns the value of attribute condition.



9
10
11
# File 'lib/postscript/model/operators/control_flow.rb', line 9

def condition
  @condition
end

Class Method Details

.from_operands(stack) ⇒ Object



15
16
17
18
19
# File 'lib/postscript/model/operators/control_flow.rb', line 15

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