module RSchema::Coercers::Float

Coerces values into `Float` objects using `Kernel#Float`

Public Instance Methods

build(_schema) click to toggle source
# File lib/rschema/coercers/float.rb, line 11
def build(_schema)
  self
end
call(value) click to toggle source
# File lib/rschema/coercers/float.rb, line 15
def call(value)
  flt = begin
          Float(value)
        rescue
          nil
        end
  flt ? Result.success(flt) : Result.failure
end
will_affect?(value) click to toggle source
# File lib/rschema/coercers/float.rb, line 24
def will_affect?(value)
  !value.is_a?(Float)
end