Sha256: fc68cf9f5b2a84e3450f38134e1f3855dfdcb0dcf8795806df47cc2d21b61815

Contents?: true

Size: 551 Bytes

Versions: 9

Compression:

Stored size: 551 Bytes

Contents

# encoding: utf-8

module Mixture
  module Coerce
    # Handles coercion of the Float class.
    class Float < Base
      type Types::Float

      coerce_to(Types::Object, Itself)
      coerce_to(Types::String, :to_s)
      coerce_to(Types::Float, Itself)
      coerce_to(Types::Integer, :to_i)
      coerce_to(Types::Rational, :to_r)
      coerce_to(Types::Time) { |value| ::Time.at(value) }
      coerce_to(Types::Date) { |value| ::Time.at(value).to_date }
      coerce_to(Types::DateTime) { |value| ::Time.at(value).to_datetime }
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mixture-0.5.1 lib/mixture/coerce/float.rb
mixture-0.5.0 lib/mixture/coerce/float.rb
mixture-0.4.0 lib/mixture/coerce/float.rb
mixture-0.3.6 lib/mixture/coerce/float.rb
mixture-0.3.5 lib/mixture/coerce/float.rb
mixture-0.3.4 lib/mixture/coerce/float.rb
mixture-0.3.2 lib/mixture/coerce/float.rb
mixture-0.3.1 lib/mixture/coerce/float.rb
mixture-0.3.0 lib/mixture/coerce/float.rb