Class: Postsvg::Model::Operators::Stack::Index

Inherits:
Postsvg::Model::Operator show all
Defined in:
lib/postsvg/model/operators/stack.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(index:) ⇒ Index

Returns a new instance of Index.



38
39
40
41
# File 'lib/postsvg/model/operators/stack.rb', line 38

def initialize(index:)
  @index = index
  freeze
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



37
38
39
# File 'lib/postsvg/model/operators/stack.rb', line 37

def index
  @index
end

Class Method Details

.from_operands(stack) ⇒ Object



42
43
44
# File 'lib/postsvg/model/operators/stack.rb', line 42

def self.from_operands(stack)
  new(index: stack.pop_number.to_i)
end