Class: FlatKit::FieldType::FloatType
- Inherits:
-
FieldType
- Object
- FieldType
- FlatKit::FieldType::FloatType
- Defined in:
- lib/flat_kit/field_type/float_type.rb
Overview
Internal: Represeting floating point data and conversion to it
Class Method Summary collapse
Class Method Details
.coerce(data) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/flat_kit/field_type/float_type.rb', line 27 def self.coerce(data) Float(data) rescue TypeError => _e CoerceFailure rescue ArgumentError => _e CoerceFailure end |
.matches?(data) ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/flat_kit/field_type/float_type.rb', line 12 def self.matches?(data) case data when Float true when Integer false when String return false if IntegerType.matches?(data) maybe_float?(data) else false end end |
.maybe_float?(data) ⇒ Boolean
35 36 37 38 39 40 |
# File 'lib/flat_kit/field_type/float_type.rb', line 35 def self.maybe_float?(data) Float(data) true rescue ArgumentError => _e false end |
.type_name ⇒ Object
8 9 10 |
# File 'lib/flat_kit/field_type/float_type.rb', line 8 def self.type_name "float" end |