Class: Postscript::Model::Operators::Stack::Roll
- Inherits:
-
Postscript::Model::Operator
- Object
- Postscript::Model::Operator
- Postscript::Model::Operators::Stack::Roll
- Defined in:
- lib/postscript/model/operators/stack.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#positions ⇒ Object
readonly
Returns the value of attribute positions.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(count:, positions:) ⇒ Roll
constructor
A new instance of Roll.
Methods inherited from Postscript::Model::Operator
#accept, #operator?, register_as
Constructor Details
#initialize(count:, positions:) ⇒ Roll
Returns a new instance of Roll.
50 51 52 53 54 |
# File 'lib/postscript/model/operators/stack.rb', line 50 def initialize(count:, positions:) @count = count @positions = positions freeze end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
49 50 51 |
# File 'lib/postscript/model/operators/stack.rb', line 49 def count @count end |
#positions ⇒ Object (readonly)
Returns the value of attribute positions.
49 50 51 |
# File 'lib/postscript/model/operators/stack.rb', line 49 def positions @positions end |
Class Method Details
.from_operands(stack) ⇒ Object
55 56 57 58 59 |
# File 'lib/postscript/model/operators/stack.rb', line 55 def self.from_operands(stack) positions = stack.pop_number.to_i count = stack.pop_number.to_i new(count: count, positions: positions) end |