Sha256: 2e7c7b8c8483ff519b88d16c355d495a05183c336df6c7793972566fca6c0f7b

Contents?: true

Size: 447 Bytes

Versions: 6

Compression:

Stored size: 447 Bytes

Contents

require 'parameters/types/object'

module Parameters
  module Types
    class Float < Object

      #
      # The coerces a value into a Float.
      #
      # @param [#to_f, ::String] value
      #   The value to coerce.
      #
      # @return [::Float]
      #   The coerced Float.
      #
      def self.coerce(value)
        if value.respond_to?(:to_f)
          value.to_f
        else
          0.0
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
parameters-0.4.4 lib/parameters/types/float.rb
parameters-0.4.3 lib/parameters/types/float.rb
parameters-0.4.2 lib/parameters/types/float.rb
parameters-0.4.0 lib/parameters/types/float.rb
parameters-0.3.1 lib/parameters/types/float.rb
parameters-0.3.0 lib/parameters/types/float.rb