Class: Postscript::Model::Operators::ControlFlow::For

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(initial:, increment:, limit:, body:) ⇒ For

Returns a new instance of For.



69
70
71
72
73
74
75
# File 'lib/postscript/model/operators/control_flow.rb', line 69

def initialize(initial:, increment:, limit:, body:)
  @initial = initial
  @increment = increment
  @limit = limit
  @body = body
  freeze
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



68
69
70
# File 'lib/postscript/model/operators/control_flow.rb', line 68

def body
  @body
end

#incrementObject (readonly)

Returns the value of attribute increment.



68
69
70
# File 'lib/postscript/model/operators/control_flow.rb', line 68

def increment
  @increment
end

#initialObject (readonly)

Returns the value of attribute initial.



68
69
70
# File 'lib/postscript/model/operators/control_flow.rb', line 68

def initial
  @initial
end

#limitObject (readonly)

Returns the value of attribute limit.



68
69
70
# File 'lib/postscript/model/operators/control_flow.rb', line 68

def limit
  @limit
end

Class Method Details

.from_operands(stack) ⇒ Object



76
77
78
79
80
81
82
# File 'lib/postscript/model/operators/control_flow.rb', line 76

def self.from_operands(stack)
  body = stack.pop
  limit = stack.pop_number
  increment = stack.pop_number
  initial = stack.pop_number
  new(initial: initial, increment: increment, limit: limit, body: body)
end