Sha256: 928d679f8c19921a4e166d01c277cdb1ac0c551d636b50b7dd53d48d57d7f94c

Contents?: true

Size: 1 KB

Versions: 10

Compression:

Stored size: 1 KB

Contents

module Finitio
  #
  # An AnyType generator allows capuring the set of every ruby citizen as a
  # Finitio type.
  #
  #     Any := .
  #
  # Object is used as concrete representation of the information type as the
  # Ruby `Object` class already captures everything.
  #
  #     R(.) = Object
  #
  # Accordingly, the `dress` transformation function has the signature below.
  # Note that dress always succeeds and returns its first argument.
  #
  #     dress :: Alpha  -> Object throws TypeError
  #     dress :: Object -> Object throws TypeError
  #
  class AnyType < Type

    def initialize(name = nil, metadata = nil)
      super(name, metadata)
    end

    def default_name
      "Any"
    end

    def representator
      Object
    end

    def include?(value)
      true
    end

    def dress(value, handler = nil)
      value
    end

    def ==(other)
      super || other.is_a?(AnyType)
    end
    alias :eql? :==

    def hash
      self.class.hash ^ 37
    end

  end # class AnyType
end # module Finitio

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
finitio-0.7.0 lib/finitio/type/any_type.rb
finitio-0.7.0.pre.rc4 lib/finitio/type/any_type.rb
finitio-0.7.0.pre.rc3 lib/finitio/type/any_type.rb
finitio-0.7.0.pre.rc2 lib/finitio/type/any_type.rb
finitio-0.7.0.pre.rc1 lib/finitio/type/any_type.rb
finitio-0.6.1 lib/finitio/type/any_type.rb
finitio-0.6.0 lib/finitio/type/any_type.rb
finitio-0.5.2 lib/finitio/type/any_type.rb
finitio-0.5.1 lib/finitio/type/any_type.rb
finitio-0.5.0 lib/finitio/type/any_type.rb