Class: Arithmetic::OperandNode

Inherits:
Object
  • Object
show all
Defined in:
lib/arithmetic/nodes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operand) ⇒ OperandNode

Returns a new instance of OperandNode.



5
6
7
# File 'lib/arithmetic/nodes.rb', line 5

def initialize(operand)
  @operand = operand
end

Instance Attribute Details

#operandObject

Returns the value of attribute operand.



3
4
5
# File 'lib/arithmetic/nodes.rb', line 3

def operand
  @operand
end

Instance Method Details

#evalObject



13
14
15
# File 'lib/arithmetic/nodes.rb', line 13

def eval
  BigDecimal.new(@operand)
end

#to_s(visitor, na = nil) ⇒ Object



9
10
11
# File 'lib/arithmetic/nodes.rb', line 9

def to_s(visitor, na=nil)
  visitor.call(@operand)
end