Sha256: ee50adf3e34f1d9c62a56ac74dfb6dda2a7cdd1be0c6148edb624e86250c23ff

Contents?: true

Size: 891 Bytes

Versions: 1

Compression:

Stored size: 891 Bytes

Contents

require 'parameters/types/object'

module Parameters
  module Types
    class Boolean < Type

      #
      # @return [true]
      #
      def self.type
        true
      end

      #
      # Determine if the value is a Boolean.
      #
      # @param [true, false] value
      #   The value to inspect.
      #
      # @return [::Boolean]
      #   Specifies whether the value was a Boolean.
      #
      def self.===(value)
        (value == true) || (value == false)
      end

      #
      # Coerces the value into a Boolean.
      #
      # @param [true, false, ::String, ::Symbol, nil] value
      #   The value to coerce.
      #
      # @return [true, false]
      #   The Boolean value.
      #
      def self.coerce(value)
        case value
        when FalseClass, NilClass, 'false', :false
          false
        else
          true
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
parameters-0.3.0 lib/parameters/types/boolean.rb