Sha256: 48b5d664931890931c8118bffb55ca849ddb9c6ee077da57786dd4aeb1573091

Contents?: true

Size: 616 Bytes

Versions: 2

Compression:

Stored size: 616 Bytes

Contents

# encoding: utf-8
# frozen_string_literal: true

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

      coerce_to(Types::Object, Itself)
      coerce_to(Types::Nil, Itself)
      coerce_to(Types::Boolean, Refute)
      coerce_to(Types::String) { "" }
      coerce_to(Types::Array) { [] }
      coerce_to(Types::Float) { 0.0 }
      coerce_to(Types::Hash) { {} }
      coerce_to(Types::Integer) { 0 }
      coerce_to(Types::Rational) { Rational(0, 1) }
      coerce_to(Types::Set) { Set.new }
      coerce_to(Types::Symbol) { :"" }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mixture-0.7.1 lib/mixture/coerce/nil.rb
mixture-0.7.0 lib/mixture/coerce/nil.rb