Class: Postscript::Model::Operators::ControlFlow::Repeat

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(count:, body:) ⇒ Repeat

Returns a new instance of Repeat.



42
43
44
45
46
# File 'lib/postscript/model/operators/control_flow.rb', line 42

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

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



41
42
43
# File 'lib/postscript/model/operators/control_flow.rb', line 41

def body
  @body
end

#countObject (readonly)

Returns the value of attribute count.



41
42
43
# File 'lib/postscript/model/operators/control_flow.rb', line 41

def count
  @count
end

Class Method Details

.from_operands(stack) ⇒ Object



47
48
49
50
51
# File 'lib/postscript/model/operators/control_flow.rb', line 47

def self.from_operands(stack)
  body = stack.pop
  count = stack.pop_number.to_i
  new(count: count, body: body)
end