Sha256: da9f14c42b601147a9068514097a9323b504c834567739ba8360b1257fad7d07

Contents?: true

Size: 881 Bytes

Versions: 5

Compression:

Stored size: 881 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, 'false', :false
          false
        else
          true
        end
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
parameters-0.4.4 lib/parameters/types/boolean.rb
parameters-0.4.3 lib/parameters/types/boolean.rb
parameters-0.4.2 lib/parameters/types/boolean.rb
parameters-0.4.0 lib/parameters/types/boolean.rb
parameters-0.3.1 lib/parameters/types/boolean.rb