Class: Yoda::Model::Types::GenericType
- Defined in:
- lib/yoda/model/types/generic_type.rb
Instance Attribute Summary collapse
- #base_type ⇒ Base readonly
- #type_arguments ⇒ Array<Base> readonly
Class Method Summary collapse
Instance Method Summary collapse
- #change_root(namespace) ⇒ GenericType
- #eql?(another) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(base_type, type_arguments) ⇒ GenericType
constructor
A new instance of GenericType.
- #map(&block) ⇒ self
- #resolve(registry) ⇒ Array<YARD::CodeObjects::Base, YARD::CodeObjects::Proxy>
- #to_s ⇒ String
Methods inherited from Base
Constructor Details
#initialize(base_type, type_arguments) ⇒ GenericType
Returns a new instance of GenericType.
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_type ⇒ Base (readonly)
6 7 8 |
# File 'lib/yoda/model/types/generic_type.rb', line 6 def base_type @base_type end |
#type_arguments ⇒ Array<Base> (readonly)
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
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
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
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 |
#hash ⇒ Object
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
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>
50 51 52 |
# File 'lib/yoda/model/types/generic_type.rb', line 50 def resolve(registry) base_type.resolve(registry) end |
#to_s ⇒ 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 |