Class: Arithmetic::OperandNode
- Inherits:
-
Object
- Object
- Arithmetic::OperandNode
- Defined in:
- lib/arithmetic/nodes.rb
Instance Attribute Summary collapse
-
#operand ⇒ Object
Returns the value of attribute operand.
Instance Method Summary collapse
- #eval ⇒ Object
-
#initialize(operand) ⇒ OperandNode
constructor
A new instance of OperandNode.
- #to_s(visitor, na = nil) ⇒ Object
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
#operand ⇒ Object
Returns the value of attribute operand.
3 4 5 |
# File 'lib/arithmetic/nodes.rb', line 3 def operand @operand end |
Instance Method Details
#eval ⇒ Object
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 |