Sha256: 3f8ada96691730e0212e8f9ac49069cc9a2532be8c5dc75460c7ff014121a182

Contents?: true

Size: 557 Bytes

Versions: 9

Compression:

Stored size: 557 Bytes

Contents

# encoding: utf-8

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

      coerce_to(Types::Object, Itself)
      coerce_to(Types::String, :to_s)
      coerce_to(Types::Float, :to_f)
      coerce_to(Types::Rational, :to_r)
      coerce_to(Types::Integer, Itself)
      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/integer.rb
mixture-0.5.0 lib/mixture/coerce/integer.rb
mixture-0.4.0 lib/mixture/coerce/integer.rb
mixture-0.3.6 lib/mixture/coerce/integer.rb
mixture-0.3.5 lib/mixture/coerce/integer.rb
mixture-0.3.4 lib/mixture/coerce/integer.rb
mixture-0.3.2 lib/mixture/coerce/integer.rb
mixture-0.3.1 lib/mixture/coerce/integer.rb
mixture-0.3.0 lib/mixture/coerce/integer.rb