Sha256: b1fc50931d609647ac3fdcb25d030e7fd4ee404c564edeac914e7dd110c35fcb

Contents?: true

Size: 545 Bytes

Versions: 9

Compression:

Stored size: 545 Bytes

Contents

# encoding: utf-8

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

      coerce_to(Types::Object, Itself)
      coerce_to(Types::String, :dup)
      coerce_to(Types::Symbol, :to_sym)
      coerce_to(Types::Integer, :to_i)
      coerce_to(Types::Float, :to_f)
      coerce_to(Types::Time) { |value| ::Time.parse(value) }
      coerce_to(Types::Date) { |value| ::Date.parse(value) }
      coerce_to(Types::DateTime) { |value| ::DateTime.parse(value) }
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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