Class: Module::DisjunctiveType

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



88
89
90
# File 'lib/composite_type.rb', line 88

def === x
   @_t[0] === x or @_t[1] === x
end

#>=(t) ⇒ Object



92
93
94
95
96
97
98
99
100
101
# File 'lib/composite_type.rb', line 92

def >= t
  case
  when super
    true
  when t.is_a?(self.class)
    t._t.all?{|e2| @_t.any?{|e1| e1 >= e2}}
  else
    @_t.any?{|e1| e1 >= t}
  end
end

#to_sObject



103
104
105
# File 'lib/composite_type.rb', line 103

def to_s
  @to_s ||= "(#{@_t[0]}|#{@_t[1]})".freeze
end