Class: TPPlus::Nodes::RealNode

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

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ RealNode

Returns a new instance of RealNode.



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

def initialize(value)
  @value = value
end

Instance Method Details

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



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tp_plus/nodes/real_node.rb', line 12

def eval(context,options={})
  val = if options[:as_string]
    ("%.2f" % @value).sub(/^0/,'')
  else
    @value
  end

  if @value < 0
    "(#{val})"
  else
    val
  end
end

#requires_mixed_logic?(context) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/tp_plus/nodes/real_node.rb', line 8

def requires_mixed_logic?(context)
  false
end