Class: Module::EnumeratedType

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

Constant Summary

Constants inherited from CompositeType

CompositeType::CACHE, CompositeType::CACHE_MUTEX

Constants inherited from Module

Void

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



60
61
62
63
64
65
66
67
# File 'lib/composite_type.rb', line 60

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

#>=(t) ⇒ Object



69
70
71
72
# File 'lib/composite_type.rb', line 69

def >= t
  super or
    t.is_a?(self.class) and @_t.zip(t._t).all?{|e1, e2| e1 >= e2 }
end

#to_sObject



74
75
76
# File 'lib/composite_type.rb', line 74

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