Module: CMDx::Coercions::Float

Extended by:
Float
Included in:
Float
Defined in:
lib/cmdx/coercions/float.rb

Overview

Coerces to Float via ‘Kernel#Float` (strict parsing; no silent zero).

Instance Method Summary collapse

Instance Method Details

#call(value, options = EMPTY_HASH) ⇒ Float, Coercions::Failure

Parameters:

  • value (Object)
  • options (Hash{Symbol => Object}) (defaults to: EMPTY_HASH)

Options Hash (options):

  • reserved (Object)

    for future per-coercion configuration (currently ignored)

Returns:



14
15
16
17
18
19
# File 'lib/cmdx/coercions/float.rb', line 14

def call(value, options = EMPTY_HASH)
  Float(value)
rescue ArgumentError, RangeError, TypeError
  type = I18nProxy.t("cmdx.types.float")
  Failure.new(I18nProxy.t("cmdx.coercions.into_a", type:))
end