Class: Yoda::Model::Values::UnionValue

Inherits:
Base
  • Object
show all
Defined in:
lib/yoda/model/values/union_value.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*values) ⇒ UnionValue

Returns a new instance of UnionValue.

Parameters:



9
10
11
# File 'lib/yoda/model/values/union_value.rb', line 9

def initialize(*values)
  @values = values
end

Instance Attribute Details

#valuesArray<Values::Base> (readonly)

Returns:



6
7
8
# File 'lib/yoda/model/values/union_value.rb', line 6

def values
  @values
end

Instance Method Details

#instance_valueIntersectionValue

Returns:



44
45
46
# File 'lib/yoda/model/values/union_value.rb', line 44

def instance_value
  UnionValue.new(*values.map(&:instance_value))
end

#referred_objectsObject



13
14
15
# File 'lib/yoda/model/values/union_value.rb', line 13

def referred_objects
  values.flat_map(&:referred_objects)
end

#select_constant_paths(name, **kwargs) ⇒ Array<String>

Parameters:

  • name (String, Symbol)

Returns:

  • (Array<String>)


33
34
35
36
# File 'lib/yoda/model/values/union_value.rb', line 33

def select_constant_paths(name, **kwargs)
  # Choose methods of shared ancestors
  values.first&.select_constant_paths(name, **kwargs) || []
end

#select_constant_type(name, **kwargs) ⇒ RBS::Types::t

Parameters:

  • name (String, Symbol)

Returns:

  • (RBS::Types::t)


26
27
28
29
# File 'lib/yoda/model/values/union_value.rb', line 26

def select_constant_type(name, **kwargs)
  # Choose methods of shared ancestors
  values.first&.select_constant_type(name, **kwargs) || RBS::Types::Bases::Any.new(location: nil)
end

#select_method(name, **kwargs) ⇒ Array<FunctionSignatures::Wrapper>

Parameters:

  • name (String, Symbol)

Returns:



19
20
21
22
# File 'lib/yoda/model/values/union_value.rb', line 19

def select_method(name, **kwargs)
  # Choose methods of shared ancestors
  values.first&.select_method(name, **kwargs) || []
end

#singleton_class_valueIntersectionValue

Returns:



39
40
41
# File 'lib/yoda/model/values/union_value.rb', line 39

def singleton_class_value
  UnionValue.new(*values.map(&:singleton_class_value))
end