Class: FlatKit::FieldType::FloatType
Constant Summary
CoerceFailure
Class Method Summary
collapse
best_guess, candidate_types, weight
#children, #find_child, #find_children, #inherited
Class Method Details
.coerce(data) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/flat_kit/field_type/float_type.rb', line 28
def self.coerce(data)
Float(data)
rescue TypeError => _
CoerceFailure
rescue ArgumentError => _
CoerceFailure
end
|
.matches?(data) ⇒ Boolean
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/flat_kit/field_type/float_type.rb', line 9
def self.matches?(data)
case data
when Float
true
when Integer
false
when String
return false if IntegerType.matches?(data)
begin
Float(data)
true
rescue ArgumentError => _
false
end
else
false
end
end
|
.type_name ⇒ Object
5
6
7
|
# File 'lib/flat_kit/field_type/float_type.rb', line 5
def self.type_name
"float"
end
|