Class: Yoda::Model::Types::GenericType

Inherits:
Base
  • Object
show all
Defined in:
lib/yoda/model/types/generic_type.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==

Constructor Details

#initialize(base_type, type_arguments) ⇒ GenericType

Returns a new instance of GenericType.

Parameters:



26
27
28
29
# File 'lib/yoda/model/types/generic_type.rb', line 26

def initialize(base_type, type_arguments)
  @base_type = base_type
  @type_arguments = type_arguments
end

Instance Attribute Details

#base_typeBase (readonly)

Returns:



6
7
8
# File 'lib/yoda/model/types/generic_type.rb', line 6

def base_type
  @base_type
end

#type_argumentsArray<Base> (readonly)

Returns:



9
10
11
# File 'lib/yoda/model/types/generic_type.rb', line 9

def type_arguments
  @type_arguments
end

Class Method Details

.from_key_value(base_type, key_type, value_type) ⇒ Object

Parameters:



14
15
16
# File 'lib/yoda/model/types/generic_type.rb', line 14

def self.from_key_value(base_type, key_type, value_type)
  new(base_type, [key_type, value_type])
end

Instance Method Details

#change_root(namespace) ⇒ GenericType

Parameters:

  • namespace (YARD::CodeObjects::Base)

Returns:



20
21
22
# File 'lib/yoda/model/types/generic_type.rb', line 20

def change_root(paths)
  self.class.new(base_type.change_root(paths), type_arguments.map { |type| type.change_root(paths) })
end

#eql?(another) ⇒ Boolean

Parameters:

  • another (Object)

Returns:

  • (Boolean)


32
33
34
35
36
# File 'lib/yoda/model/types/generic_type.rb', line 32

def eql?(another)
  another.is_a?(GenericType) &&
  base_type  == another.base_type &&
  type_arguments == another.type_arguments
end

#hashObject



38
39
40
# File 'lib/yoda/model/types/generic_type.rb', line 38

def hash
  [self.class.name, base_type, type_arguments].hash
end

#map(&block) ⇒ self

Returns:

  • (self)


60
61
62
# File 'lib/yoda/model/types/generic_type.rb', line 60

def map(&block)
  self.class.new(base_type.map(&block), type_arguments.map(&block))
end

#resolve(registry) ⇒ Array<YARD::CodeObjects::Base, YARD::CodeObjects::Proxy>

Parameters:

  • registry (Registry)

Returns:

  • (Array<YARD::CodeObjects::Base, YARD::CodeObjects::Proxy>)


50
51
52
# File 'lib/yoda/model/types/generic_type.rb', line 50

def resolve(registry)
  base_type.resolve(registry)
end

#to_sString

Returns:

  • (String)


55
56
57
# File 'lib/yoda/model/types/generic_type.rb', line 55

def to_s
  "#{base_type}<#{type_arguments.map(&:to_s).join(', ')}>"
end