Class: KDL::Value::Float
- Inherits:
-
KDL::Value
- Object
- KDL::Value
- KDL::Value::Float
- Defined in:
- lib/kdl/value.rb
Direct Known Subclasses
Constant Summary
Constants inherited from KDL::Value
Instance Attribute Summary
Attributes inherited from KDL::Value
Instance Method Summary collapse
Methods inherited from KDL::Value
#as_type, from, #initialize, #inspect, #method_missing, #respond_to_missing?, #to_s, #to_v2, #version
Constructor Details
This class inherits a constructor from KDL::Value
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class KDL::Value
Instance Method Details
#==(other) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/kdl/value.rb', line 75 def ==(other) return self == other.value if other.is_a?(Float) return other.nan? if value.nan? value == other end |
#stringify_value ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/kdl/value.rb', line 82 def stringify_value return '#nan' if value.nan? return '#inf' if value == ::Float::INFINITY return '#-inf' if value == -::Float::INFINITY return super.upcase unless value.is_a?(BigDecimal) sign, digits, _, exponent = value.split s = +'' s << '-' if sign.negative? s << "#{digits[0]}.#{digits[1..-1]}" s << "E#{exponent.negative? ? '' : '+'}#{exponent - 1}" s end |