Class: Plumb::Codec::DecimalEncoder
- Inherits:
-
Object
- Object
- Plumb::Codec::DecimalEncoder
- Defined in:
- lib/plumb/codec.rb
Overview
BigDecimal <=> canonical decimal string ("1.5"). A string, not a number: decimals exist to avoid float precision loss, and JSON numbers are floats. In Codec::JSON this also keeps Decimal fields from silently noop-passing via the Numeric noop (a BigDecimal is not JSON-native).
Instance Method Summary collapse
Instance Method Details
#decode(str) ⇒ Object
742 |
# File 'lib/plumb/codec.rb', line 742 def decode(str) = BigDecimal(str) |
#encode(dec) ⇒ Object
741 |
# File 'lib/plumb/codec.rb', line 741 def encode(dec) = dec.to_s('F') |