Class: Postscript::Model::Operators::Dictionary::Def

Inherits:
Postscript::Model::Operator show all
Defined in:
lib/postscript/model/operators/dictionary.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(key:, value:) ⇒ Def

Returns a new instance of Def.



34
35
36
37
38
# File 'lib/postscript/model/operators/dictionary.rb', line 34

def initialize(key:, value:)
  @key = key
  @value = value
  freeze
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



33
34
35
# File 'lib/postscript/model/operators/dictionary.rb', line 33

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



33
34
35
# File 'lib/postscript/model/operators/dictionary.rb', line 33

def value
  @value
end

Class Method Details

.from_operands(stack) ⇒ Object



39
40
41
42
43
# File 'lib/postscript/model/operators/dictionary.rb', line 39

def self.from_operands(stack)
  value = stack.pop
  key = stack.pop
  new(key: key, value: value)
end