Class: Postscript::Model::Operators::Arithmetic::Div

Inherits:
Postscript::Model::Operator show all
Defined in:
lib/postscript/model/operators/arithmetic.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(operand_a:, operand_b:) ⇒ Div

Returns a new instance of Div.



63
64
65
66
67
# File 'lib/postscript/model/operators/arithmetic.rb', line 63

def initialize(operand_a:, operand_b:)
  @operand_a = operand_a
  @operand_b = operand_b
  freeze
end

Instance Attribute Details

#operand_aObject (readonly)

Returns the value of attribute operand_a.



62
63
64
# File 'lib/postscript/model/operators/arithmetic.rb', line 62

def operand_a
  @operand_a
end

#operand_bObject (readonly)

Returns the value of attribute operand_b.



62
63
64
# File 'lib/postscript/model/operators/arithmetic.rb', line 62

def operand_b
  @operand_b
end

Class Method Details

.from_operands(stack) ⇒ Object



57
58
59
60
61
# File 'lib/postscript/model/operators/arithmetic.rb', line 57

def self.from_operands(stack)
  b = stack.pop_number
  a = stack.pop_number
  new(operand_a: a, operand_b: b)
end