Class: Virtus::Coercion::Float
- Inherits:
-
Numeric
- Object
- Virtus::Coercion
- Object
- Numeric
- Virtus::Coercion::Float
- Defined in:
- lib/virtus/coercion/float.rb
Overview
Coerce Float values
Constant Summary
Constants inherited from Object
Object::COERCION_METHOD_REGEXP
Constants included from TypeLookup
Class 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
to_array, to_hash, to_integer, to_string
Methods inherited from Virtus::Coercion
Methods included from TypeLookup
#determine_type, extended, #primitive
Methods included from Options
#accept_options, #accepted_options, #options
Class Method Details
.to_datetime(value) ⇒ DateTime
Coerce given value to a DateTime
33 34 35 |
# File 'lib/virtus/coercion/float.rb', line 33 def self.to_datetime(value) ::DateTime.strptime((value * 10**3).to_s, "%Q") end |
.to_float(value) ⇒ Integer
Passthrough the value
18 19 20 |
# File 'lib/virtus/coercion/float.rb', line 18 def self.to_float(value) value end |