Sha256: de9e4ce7c5e018e74962f207f918899f8fa789d62b2cf9de54ef13e7357dc982

Contents?: true

Size: 1 KB

Versions: 9

Compression:

Stored size: 1 KB

Contents

module Finitio
  module CollectionType

    def initialize(elm_type, name = nil, metadata = nil)
      unless elm_type.is_a?(Type)
        raise ArgumentError, "Finitio::Type expected, got `#{elm_type}`"
      end

      super(name, metadata)
      @elm_type = elm_type
    end
    attr_reader :elm_type

    def ==(other)
      super || (other.is_a?(self.class) && elm_type == other.elm_type)
    end
    alias :eql? :==

    def hash
      self.class.hash ^ self.elm_type.hash
    end

    def suppremum(other)
      return super unless other.is_a?(CollectionType)
      return self if other.is_a?(CollectionType) && elm_type == other.elm_type
      builder = self.class == other.class ? self.class : SeqType
      builder.new(elm_type.suppremum(other.elm_type))
    end

    def resolve_proxies(system)
      self.class.new(elm_type.resolve_proxies(system), name, metadata)
    end

    def unconstrained
      self.class.new(elm_type.unconstrained, name, metadata)
    end

  end # module CollectionType
end # module Finitio

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
finitio-0.12.0 lib/finitio/type/collection_type.rb
finitio-0.11.4 lib/finitio/type/collection_type.rb
finitio-0.11.3 lib/finitio/type/collection_type.rb
finitio-0.11.2 lib/finitio/type/collection_type.rb
finitio-0.11.1 lib/finitio/type/collection_type.rb
finitio-0.10.0 lib/finitio/type/collection_type.rb
finitio-0.9.1 lib/finitio/type/collection_type.rb
finitio-0.9.0 lib/finitio/type/collection_type.rb
finitio-0.8.0 lib/finitio/type/collection_type.rb