Class: KDL::Value::Float

Inherits:
KDL::Value show all
Defined in:
lib/kdl/value.rb

Constant Summary

Constants inherited from KDL::Value

Null

Instance Attribute Summary

Attributes inherited from KDL::Value

#format, #type, #value

Instance Method Summary collapse

Methods inherited from KDL::Value

#as_type, from, #initialize, #to_s

Constructor Details

This class inherits a constructor from KDL::Value

Instance Method Details

#==(other) ⇒ Object



45
46
47
# File 'lib/kdl/value.rb', line 45

def ==(other)
  other.is_a?(Float) && value == other.value
end

#stringify_valueObject



49
50
51
52
53
54
55
56
57
# File 'lib/kdl/value.rb', line 49

def stringify_value
  return super.upcase unless value.is_a?(BigDecimal)

  sign, digits, _, exponent = value.split
  s = sign.negative? ? '-' : ''
  s += "#{digits[0]}.#{digits[1..-1]}"
  s += "E#{exponent.negative? ? '' : '+'}#{exponent - 1}"
  s
end