Class: Coercible::Coercer::Float
- Defined in:
- lib/coercible/coercer/float.rb
Overview
Coerce Float values
Constant Summary
Constants inherited from Object
Object::COERCION_METHOD_REGEXP
Constants included from Options
Constants included from TypeLookup
Instance Attribute Summary
Attributes inherited from Object
Instance Method Summary collapse
-
#to_datetime(value) ⇒ DateTime
Coerce given value to a DateTime.
-
#to_float(value) ⇒ Integer
Passthrough the value.
Methods inherited from Numeric
#to_decimal, #to_integer, #to_string
Methods inherited from Object
#coerced?, #initialize, #inspect, #to_array, #to_hash, #to_integer, #to_string
Methods included from Options
#accept_options, #accepted_options, extended, #options
Methods included from TypeLookup
#determine_type, extended, #primitive
Constructor Details
This class inherits a constructor from Coercible::Coercer::Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Coercible::Coercer::Object
Instance Method Details
#to_datetime(value) ⇒ DateTime
Coerce given value to a DateTime
33 34 35 |
# File 'lib/coercible/coercer/float.rb', line 33 def to_datetime(value) ::DateTime.strptime((value * 10**3).to_s, "%Q") end |
#to_float(value) ⇒ Integer
Passthrough the value
18 19 20 |
# File 'lib/coercible/coercer/float.rb', line 18 def to_float(value) value end |