Class: Rbdantic::Validators::Types::Float
- Inherits:
-
Number
- Object
- Base
- Number
- Rbdantic::Validators::Types::Float
show all
- Defined in:
- lib/rbdantic/validators/types/float.rb
Constant Summary
Constants inherited
from Number
Number::FLOAT_TOLERANCE_FACTOR, Number::MIN_FLOAT_TOLERANCE
Instance Attribute Summary
Attributes inherited from Base
#constraints
Instance Method Summary
collapse
Methods inherited from Number
#validate_constraints
Methods inherited from Base
#initialize, #validate, #validate_constraints
Instance Method Details
#coerce(value) ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/rbdantic/validators/types/float.rb', line 21
def coerce(value)
case value
when ::Float then value
when ::Integer then value.to_f
when ::String then Float(value) rescue nil
else nil
end
end
|
#expected_type_name ⇒ Object
13
14
15
|
# File 'lib/rbdantic/validators/types/float.rb', line 13
def expected_type_name
"Float"
end
|
#matches_type?(value) ⇒ Boolean
9
10
11
|
# File 'lib/rbdantic/validators/types/float.rb', line 9
def matches_type?(value)
value.is_a?(::Float)
end
|
#numeric_type? ⇒ Boolean
17
18
19
|
# File 'lib/rbdantic/validators/types/float.rb', line 17
def numeric_type?
true
end
|