Class: SyntaxTree::Reflection::Type::UnionType
- Inherits:
-
Object
- Object
- SyntaxTree::Reflection::Type::UnionType
- Defined in:
- lib/syntax_tree/reflection.rb
Overview
Represents a union type that can be one of a number of types.
Instance Attribute Summary collapse
-
#types ⇒ Object
readonly
Returns the value of attribute types.
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.
52 53 54 |
# File 'lib/syntax_tree/reflection.rb', line 52 def initialize(types) @types = types end |
Instance Attribute Details
#types ⇒ Object (readonly)
Returns the value of attribute types.
50 51 52 |
# File 'lib/syntax_tree/reflection.rb', line 50 def types @types end |
Instance Method Details
#===(value) ⇒ Object
56 57 58 |
# File 'lib/syntax_tree/reflection.rb', line 56 def ===(value) types.any? { _1 === value } end |
#inspect ⇒ Object
60 61 62 |
# File 'lib/syntax_tree/reflection.rb', line 60 def inspect types.map(&:inspect).join(" | ") end |