Class: Acfs::Resource::Attributes::Float
- Defined in:
- lib/acfs/resource/attributes/float.rb
Overview
Float attribute type. Use it in your model as an attribute type:
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#cast_value(value) ⇒ Float
Cast given object to float.
Methods inherited from Base
#cast, #default_value, #initialize
Constructor Details
This class inherits a constructor from Acfs::Resource::Attributes::Base
Instance Method Details
#cast_value(value) ⇒ Float
Cast given object to float.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/acfs/resource/attributes/float.rb', line 21 def cast_value(value) return 0.0 if value.blank? case value when ::Float then value when 'Infinity' then ::Float::INFINITY when '-Infinity' then -::Float::INFINITY when 'NaN' then ::Float::NAN else Float(value) end end |