Class: TypeStruct::Union
- Inherits:
-
Object
- Object
- TypeStruct::Union
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/type_struct/union.rb
Instance Method Summary collapse
- #===(other) ⇒ Object
-
#initialize(*classes) ⇒ Union
constructor
A new instance of Union.
- #to_s ⇒ Object (also: #inspect)
- #|(other) ⇒ Object
Constructor Details
#initialize(*classes) ⇒ Union
Returns a new instance of Union.
8 9 10 |
# File 'lib/type_struct/union.rb', line 8 def initialize(*classes) @classes = classes end |
Instance Method Details
#===(other) ⇒ Object
16 17 18 |
# File 'lib/type_struct/union.rb', line 16 def ===(other) @classes.any? { |c| c === other } end |
#to_s ⇒ Object Also known as: inspect
20 21 22 |
# File 'lib/type_struct/union.rb', line 20 def to_s "#<#{self.class} #{@classes.join('|')}>" end |