Class: Module::EnumeratedType

Inherits:
CompositeType show all
Defined in:
lib/composite_type.rb

Constant Summary

Constants inherited from CompositeType

CompositeType::CACHE, CompositeType::CACHE_MUTEX

Instance Attribute Summary

Attributes inherited from CompositeType

#_t

Instance Method Summary collapse

Methods inherited from CompositeType

#initialize, #name, new_cached

Methods inherited from Module

#&, #of, #with, #|, #~@

Constructor Details

This class inherits a constructor from Module::CompositeType

Instance Method Details

#===(x) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/composite_type.rb', line 49

def === x
  Enumerable === x and
    @_t.size == x.size and
    begin
      i = -1
      @_t.all?{|t| t === x[i += 1]}
    end
end

#to_sObject



57
58
59
# File 'lib/composite_type.rb', line 57

def to_s
  @to_s ||= "#{@_t[0]}.with(#{@_t[1..-1] * ','})".freeze
end