Sha256: 5ecfed55da19a0c249a7a9f396bbde1e2cf3986e3f61147aff36108743257d3d

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module Parameters
  module Types
    class Type

      #
      # The Ruby Class the type represents.
      #
      # @return [Class]
      #   A Ruby Class the Type represents.
      #
      # @abstract
      #
      def self.to_ruby
      end

      #
      # @see to_ruby
      #
      def to_ruby
        self.class.to_ruby
      end

      #
      # Determines if the value is an instance of the Type.
      #
      # @return [Boolean]
      #   Specifies whether the value is already an instance of the Type.
      #
      # @abstract
      #
      def self.===(value)
        false
      end

      #
      # Coerces an Object into an instances of the Type.
      #
      # @param [Object] value
      #   The value to coerce.
      #
      # @return [Object]
      #   The coerced value.
      #
      # @abstract
      #
      def self.coerce(value)
      end

      #
      # @see ===
      #
      def ===(value)
        self.class === value
      end

      #
      # @see coerce
      #
      def coerce(value)
        self.class.coerce(value)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
parameters-0.3.1 lib/parameters/types/type.rb
parameters-0.3.0 lib/parameters/types/type.rb