Class: Ronin::Core::Params::Types::Float
- Defined in:
- lib/ronin/core/params/types/float.rb
Overview
Represents a true/false param.
Instance Attribute Summary
Attributes inherited from Numeric
Instance Method Summary collapse
-
#coerce(value) ⇒ ::Float
private
Coerces a value into a Float value.
Methods inherited from Numeric
Constructor Details
This class inherits a constructor from Ronin::Core::Params::Types::Numeric
Instance Method Details
#coerce(value) ⇒ ::Float
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Coerces a value into a Float value.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ronin/core/params/types/float.rb', line 45 def coerce(value) case value when ::Float super(value) when ::String if value =~ /\A[+-]?\d+(?:\.\d+)?\z/ super(value.to_f) else raise(ValidationError,"value contains non-numeric characters (#{value.inspect})") end else if value.respond_to?(:to_f) super(value.to_f) else raise(ValidationError,"value does not define a #to_f method (#{value.inspect})") end end end |