Class: PokeApiClient::TypeDetail
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- PokeApiClient::TypeDetail
- Defined in:
- lib/pokeapi_client/models/type_detail.rb
Overview
Serializer for the Type resource
Instance Attribute Summary collapse
-
#damage_relations ⇒ Object
Returns the value of attribute damage_relations.
-
#game_indices ⇒ Object
Returns the value of attribute game_indices.
-
#generation ⇒ Object
Returns the value of attribute generation.
-
#id ⇒ Object
Returns the value of attribute id.
-
#move_damage_class ⇒ Object
Returns the value of attribute move_damage_class.
-
#moves ⇒ Object
Returns the value of attribute moves.
-
#name ⇒ Object
Returns the value of attribute name.
-
#names ⇒ Object
Returns the value of attribute names.
-
#past_damage_relations ⇒ Object
Returns the value of attribute past_damage_relations.
-
#pokemon ⇒ Object
Returns the value of attribute pokemon.
-
#sprites ⇒ Object
Returns the value of attribute sprites.
Class Method Summary collapse
-
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ TypeDetail
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Methods inherited from ApiModelBase
_deserialize, #_to_hash, #to_body, #to_s
Constructor Details
#initialize(attributes = {}) ⇒ TypeDetail
Initializes the object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 93 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `PokeApiClient::TypeDetail` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key acceptable_attribute_map = self.class.acceptable_attribute_map attributes = attributes.each_with_object({}) { |(k, v), h| if (!acceptable_attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `PokeApiClient::TypeDetail`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'id') self.id = attributes[:'id'] else self.id = nil end if attributes.key?(:'name') self.name = attributes[:'name'] else self.name = nil end if attributes.key?(:'damage_relations') self.damage_relations = attributes[:'damage_relations'] else self.damage_relations = nil end if attributes.key?(:'past_damage_relations') if (value = attributes[:'past_damage_relations']).is_a?(Array) self.past_damage_relations = value end else self.past_damage_relations = nil end if attributes.key?(:'game_indices') if (value = attributes[:'game_indices']).is_a?(Array) self.game_indices = value end else self.game_indices = nil end if attributes.key?(:'generation') self.generation = attributes[:'generation'] else self.generation = nil end if attributes.key?(:'move_damage_class') self.move_damage_class = attributes[:'move_damage_class'] else self.move_damage_class = nil end if attributes.key?(:'names') if (value = attributes[:'names']).is_a?(Array) self.names = value end else self.names = nil end if attributes.key?(:'pokemon') if (value = attributes[:'pokemon']).is_a?(Array) self.pokemon = value end else self.pokemon = nil end if attributes.key?(:'moves') if (value = attributes[:'moves']).is_a?(Array) self.moves = value end else self.moves = nil end if attributes.key?(:'sprites') if (value = attributes[:'sprites']).is_a?(Hash) self.sprites = value end else self.sprites = nil end end |
Instance Attribute Details
#damage_relations ⇒ Object
Returns the value of attribute damage_relations.
23 24 25 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 23 def damage_relations @damage_relations end |
#game_indices ⇒ Object
Returns the value of attribute game_indices.
27 28 29 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 27 def game_indices @game_indices end |
#generation ⇒ Object
Returns the value of attribute generation.
29 30 31 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 29 def generation @generation end |
#id ⇒ Object
Returns the value of attribute id.
19 20 21 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 19 def id @id end |
#move_damage_class ⇒ Object
Returns the value of attribute move_damage_class.
31 32 33 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 31 def move_damage_class @move_damage_class end |
#moves ⇒ Object
Returns the value of attribute moves.
37 38 39 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 37 def moves @moves end |
#name ⇒ Object
Returns the value of attribute name.
21 22 23 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 21 def name @name end |
#names ⇒ Object
Returns the value of attribute names.
33 34 35 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 33 def names @names end |
#past_damage_relations ⇒ Object
Returns the value of attribute past_damage_relations.
25 26 27 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 25 def past_damage_relations @past_damage_relations end |
#pokemon ⇒ Object
Returns the value of attribute pokemon.
35 36 37 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 35 def pokemon @pokemon end |
#sprites ⇒ Object
Returns the value of attribute sprites.
39 40 41 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 39 def sprites @sprites end |
Class Method Details
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
59 60 61 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 59 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
64 65 66 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 64 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 42 def self.attribute_map { :'id' => :'id', :'name' => :'name', :'damage_relations' => :'damage_relations', :'past_damage_relations' => :'past_damage_relations', :'game_indices' => :'game_indices', :'generation' => :'generation', :'move_damage_class' => :'move_damage_class', :'names' => :'names', :'pokemon' => :'pokemon', :'moves' => :'moves', :'sprites' => :'sprites' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 408 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
86 87 88 89 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 86 def self.openapi_nullable Set.new([ ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 69 def self.openapi_types { :'id' => :'Integer', :'name' => :'String', :'damage_relations' => :'TypeDetailDamageRelations', :'past_damage_relations' => :'Array<TypeDetailPastDamageRelationsInner>', :'game_indices' => :'Array<TypeGameIndex>', :'generation' => :'GenerationSummary', :'move_damage_class' => :'MoveDamageClassSummary', :'names' => :'Array<AbilityName>', :'pokemon' => :'Array<TypeDetailPokemonInner>', :'moves' => :'Array<MoveSummary>', :'sprites' => :'Hash<String, Hash<String, TypeDetailSpritesValueValue>>' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 377 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && name == o.name && damage_relations == o.damage_relations && past_damage_relations == o.past_damage_relations && game_indices == o.game_indices && generation == o.generation && move_damage_class == o.move_damage_class && names == o.names && pokemon == o.pokemon && moves == o.moves && sprites == o.sprites end |
#eql?(o) ⇒ Boolean
395 396 397 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 395 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
401 402 403 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 401 def hash [id, name, damage_relations, past_damage_relations, game_indices, generation, move_damage_class, names, pokemon, moves, sprites].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 188 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new if @id.nil? invalid_properties.push('invalid value for "id", id cannot be nil.') end if @name.nil? invalid_properties.push('invalid value for "name", name cannot be nil.') end if @name.to_s.length > 100 invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 100.') end if @damage_relations.nil? invalid_properties.push('invalid value for "damage_relations", damage_relations cannot be nil.') end if @past_damage_relations.nil? invalid_properties.push('invalid value for "past_damage_relations", past_damage_relations cannot be nil.') end if @game_indices.nil? invalid_properties.push('invalid value for "game_indices", game_indices cannot be nil.') end if @generation.nil? invalid_properties.push('invalid value for "generation", generation cannot be nil.') end if @move_damage_class.nil? invalid_properties.push('invalid value for "move_damage_class", move_damage_class cannot be nil.') end if @names.nil? invalid_properties.push('invalid value for "names", names cannot be nil.') end if @pokemon.nil? invalid_properties.push('invalid value for "pokemon", pokemon cannot be nil.') end if @moves.nil? invalid_properties.push('invalid value for "moves", moves cannot be nil.') end if @sprites.nil? invalid_properties.push('invalid value for "sprites", sprites cannot be nil.') end invalid_properties end |
#to_hash ⇒ Hash
Returns the object in the form of hash
430 431 432 433 434 435 436 437 438 439 440 441 442 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 430 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/pokeapi_client/models/type_detail.rb', line 244 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if @id.nil? return false if @name.nil? return false if @name.to_s.length > 100 return false if @damage_relations.nil? return false if @past_damage_relations.nil? return false if @game_indices.nil? return false if @generation.nil? return false if @move_damage_class.nil? return false if @names.nil? return false if @pokemon.nil? return false if @moves.nil? return false if @sprites.nil? true end |