Class: TPPlus::Nodes::DigitNode

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ DigitNode

Returns a new instance of DigitNode.



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

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/tp_plus/nodes/digit_node.rb', line 4

def value
  @value
end

Instance Method Details

#eval(context, options = {}) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/tp_plus/nodes/digit_node.rb', line 13

def eval(context, options={})
  if @value < 0
    "(#{@value})"
  else
    @value
  end
end

#requires_mixed_logic?(context) ⇒ Boolean

Returns:

  • (Boolean)


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

def requires_mixed_logic?(context)
  false
end