Class: Superstore::Types::FloatType
- Defined in:
- lib/superstore/types/float_type.rb
Constant Summary collapse
- REGEX =
/\A[-+]?\d+(\.\d+)?\Z/
Instance Attribute Summary
Attributes inherited from BaseType
Instance Method Summary collapse
Methods inherited from BaseType
#default, #initialize, #typecast
Constructor Details
This class inherits a constructor from Superstore::Types::BaseType
Instance Method Details
#decode(str) ⇒ Object
10 11 12 13 |
# File 'lib/superstore/types/float_type.rb', line 10 def decode(str) return nil if str.empty? str.to_f end |
#encode(float) ⇒ Object
5 6 7 8 |
# File 'lib/superstore/types/float_type.rb', line 5 def encode(float) raise ArgumentError.new("#{float.inspect} is not a Float") unless float.kind_of?(Float) float.to_s end |