Class: StoreSchema::Converter::Float
- Inherits:
-
Object
- Object
- StoreSchema::Converter::Float
- Includes:
- Base
- Defined in:
- lib/store_schema/converter/float.rb
Instance Attribute Summary
Attributes included from Base
Instance Method Summary collapse
-
#from_db ⇒ Float
Converts the Base#value to a Ruby-type value.
-
#to_db ⇒ String, false
Converts the Base#value to a database-storable value.
Methods included from Base
Instance Method Details
#from_db ⇒ Float
Converts the Base#value to a Ruby-type value.
31 32 33 |
# File 'lib/store_schema/converter/float.rb', line 31 def from_db value.to_f end |
#to_db ⇒ String, false
Converts the Base#value to a database-storable value.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/store_schema/converter/float.rb', line 10 def to_db case value when ::Integer value.to_f.to_s when ::Float value.to_s when ::String if value =~ /^\d+|\d+\.\d+$/ value.to_f.to_s else false end else false end end |