Sha256: 9be07f0d32d76487fa4a8856688f7ecaea4614e32f65cb636089383565e316a6
Contents?: true
Size: 644 Bytes
Versions: 2
Compression:
Stored size: 644 Bytes
Contents
# encoding: utf-8 # frozen_string_literal: true 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::Boolean) { |value| !value.zero? } 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mixture-0.7.1 | lib/mixture/coerce/integer.rb |
mixture-0.7.0 | lib/mixture/coerce/integer.rb |