Sha256: 386f4f81d19acaa0fc6dc7b1b4744e069d2992b1b4fef9e9e3b3f62c860d0084

Contents?: true

Size: 548 Bytes

Versions: 2

Compression:

Stored size: 548 Bytes

Contents

# encoding: utf-8

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mixture-0.2.0 lib/mixture/coerce/integer.rb
mixture-0.1.0 lib/mixture/coerce/integer.rb