Class: Literal::Types::UnionType
- Inherits:
-
Object
- Object
- Literal::Types::UnionType
- Defined in:
- lib/literal/types/union_type.rb
Instance Method Summary collapse
- #===(value) ⇒ Object
-
#initialize(*types) ⇒ UnionType
constructor
A new instance of UnionType.
- #inspect ⇒ Object
Constructor Details
#initialize(*types) ⇒ UnionType
Returns a new instance of UnionType.
2 3 4 |
# File 'lib/literal/types/union_type.rb', line 2 def initialize(*types) @types = types end |
Instance Method Details
#===(value) ⇒ Object
10 11 12 |
# File 'lib/literal/types/union_type.rb', line 10 def ===(value) @types.any? { |type| type === value } end |
#inspect ⇒ Object
6 7 8 |
# File 'lib/literal/types/union_type.rb', line 6 def inspect "Union(#{@types.map(&:inspect).join(", ")})" end |