Class: SyntaxTree::Reflection::Type::UnionType

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#typesObject (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

#inspectObject



60
61
62
# File 'lib/syntax_tree/reflection.rb', line 60

def inspect
  types.map(&:inspect).join(" | ")
end