Class: ContainerConfig::Coercer::Float

Inherits:
Base
  • Object
show all
Defined in:
lib/container_config/coercer/float.rb

Overview

Float type coercer

Instance Method Summary collapse

Instance Method Details

#coerce(value) ⇒ Float

Coerces the given value into a float

Parameters:

  • value (Object)

    given value

Returns:

  • (Float)

    coerced value



26
27
28
29
30
# File 'lib/container_config/coercer/float.rb', line 26

def coerce(value)
  return 0.0 unless value.respond_to?(:to_f)

  value.to_f
end

#nameObject

See Also:



10
11
12
# File 'lib/container_config/coercer/float.rb', line 10

def name
  "Float"
end

#typeObject

See Also:



15
16
17
# File 'lib/container_config/coercer/float.rb', line 15

def type
  :float
end