Class: FlatKit::FieldType::IntegerType
Constant Summary
collapse
- REGEX =
/\A[-+]?\d+\Z/
CoerceFailure
Class Method Summary
collapse
best_guess, candidate_types, weight
#children, #find_child, #find_children, #inherited
Class Method Details
.coerce(data) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/flat_kit/field_type/integer_type.rb', line 24
def self.coerce(data)
Integer(data)
rescue TypeError => _
CoerceFailure
rescue ArgumentError => _
CoerceFailure
end
|
.matches?(data) ⇒ Boolean
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/flat_kit/field_type/integer_type.rb', line 11
def self.matches?(data)
case data
when Integer
true
when Float
false
when String
REGEX.match?(data)
else
false
end
end
|
.type_name ⇒ Object
7
8
9
|
# File 'lib/flat_kit/field_type/integer_type.rb', line 7
def self.type_name
"integer"
end
|