Sha256: 2db418c5a80e6bf867e7bd2c7c7f9f6b8bdb2cfee80b6dff91328ac19f8eeaf8

Contents?: true

Size: 284 Bytes

Versions: 3

Compression:

Stored size: 284 Bytes

Contents

module Compel
  module Coercion

    class Boolean < Type

      def coerce
        if /(false|f|no|n|0)$/i === "#{value}"
          return false
        end

        if /(true|t|yes|y|1)$/i === "#{value}"
          return true
        end

        fail
      end

    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
compel-0.1.3 lib/compel/coercion/boolean.rb
compel-0.1.2 lib/compel/coercion/boolean.rb
compel-0.1.1 lib/compel/coercion/boolean.rb