Class: Parameters::Types::Float

Inherits:
Object show all
Defined in:
lib/parameters/types/float.rb

Class Method Summary collapse

Methods inherited from Object

#===, ===, to_ruby

Methods inherited from Type

#<, #<=, #==, ===, #===, #coerce, #to_ruby, to_ruby

Class Method Details

.coerce(value) ⇒ ::Float

The coerces a value into a Float.

Parameters:

  • value (#to_f, ::String)

    The value to coerce.

Returns:

  • (::Float)

    The coerced Float.



16
17
18
19
20
21
22
# File 'lib/parameters/types/float.rb', line 16

def self.coerce(value)
  if value.respond_to?(:to_f)
    value.to_f
  else
    0.0
  end
end