Class: PokeApiClient::ItemDetail

Inherits:
ApiModelBase show all
Defined in:
lib/pokeapi_client/models/item_detail.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ ItemDetail

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
185
186
187
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
# File 'lib/pokeapi_client/models/item_detail.rb', line 110

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `PokeApiClient::ItemDetail` 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::ItemDetail`. 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?(:'cost')
    self.cost = attributes[:'cost']
  end

  if attributes.key?(:'fling_power')
    self.fling_power = attributes[:'fling_power']
  end

  if attributes.key?(:'fling_effect')
    self.fling_effect = attributes[:'fling_effect']
  else
    self.fling_effect = nil
  end

  if attributes.key?(:'attributes')
    if (value = attributes[:'attributes']).is_a?(Array)
      self.attributes = value
    end
  else
    self.attributes = nil
  end

  if attributes.key?(:'category')
    self.category = attributes[:'category']
  else
    self.category = nil
  end

  if attributes.key?(:'effect_entries')
    if (value = attributes[:'effect_entries']).is_a?(Array)
      self.effect_entries = value
    end
  else
    self.effect_entries = nil
  end

  if attributes.key?(:'flavor_text_entries')
    if (value = attributes[:'flavor_text_entries']).is_a?(Array)
      self.flavor_text_entries = value
    end
  else
    self.flavor_text_entries = 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?(:'names')
    if (value = attributes[:'names']).is_a?(Array)
      self.names = value
    end
  else
    self.names = nil
  end

  if attributes.key?(:'held_by_pokemon')
    if (value = attributes[:'held_by_pokemon']).is_a?(Array)
      self.held_by_pokemon = value
    end
  else
    self.held_by_pokemon = nil
  end

  if attributes.key?(:'sprites')
    self.sprites = attributes[:'sprites']
  else
    self.sprites = nil
  end

  if attributes.key?(:'baby_trigger_for')
    self.baby_trigger_for = attributes[:'baby_trigger_for']
  else
    self.baby_trigger_for = nil
  end

  if attributes.key?(:'machines')
    if (value = attributes[:'machines']).is_a?(Array)
      self.machines = value
    end
  else
    self.machines = nil
  end
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



28
29
30
# File 'lib/pokeapi_client/models/item_detail.rb', line 28

def attributes
  @attributes
end

#baby_trigger_forObject

Returns the value of attribute baby_trigger_for.



44
45
46
# File 'lib/pokeapi_client/models/item_detail.rb', line 44

def baby_trigger_for
  @baby_trigger_for
end

#categoryObject

Returns the value of attribute category.



30
31
32
# File 'lib/pokeapi_client/models/item_detail.rb', line 30

def category
  @category
end

#costObject

Returns the value of attribute cost.



22
23
24
# File 'lib/pokeapi_client/models/item_detail.rb', line 22

def cost
  @cost
end

#effect_entriesObject

Returns the value of attribute effect_entries.



32
33
34
# File 'lib/pokeapi_client/models/item_detail.rb', line 32

def effect_entries
  @effect_entries
end

#flavor_text_entriesObject

Returns the value of attribute flavor_text_entries.



34
35
36
# File 'lib/pokeapi_client/models/item_detail.rb', line 34

def flavor_text_entries
  @flavor_text_entries
end

#fling_effectObject

Returns the value of attribute fling_effect.



26
27
28
# File 'lib/pokeapi_client/models/item_detail.rb', line 26

def fling_effect
  @fling_effect
end

#fling_powerObject

Returns the value of attribute fling_power.



24
25
26
# File 'lib/pokeapi_client/models/item_detail.rb', line 24

def fling_power
  @fling_power
end

#game_indicesObject

Returns the value of attribute game_indices.



36
37
38
# File 'lib/pokeapi_client/models/item_detail.rb', line 36

def game_indices
  @game_indices
end

#held_by_pokemonObject

Returns the value of attribute held_by_pokemon.



40
41
42
# File 'lib/pokeapi_client/models/item_detail.rb', line 40

def held_by_pokemon
  @held_by_pokemon
end

#idObject

Returns the value of attribute id.



18
19
20
# File 'lib/pokeapi_client/models/item_detail.rb', line 18

def id
  @id
end

#machinesObject

Returns the value of attribute machines.



46
47
48
# File 'lib/pokeapi_client/models/item_detail.rb', line 46

def machines
  @machines
end

#nameObject

Returns the value of attribute name.



20
21
22
# File 'lib/pokeapi_client/models/item_detail.rb', line 20

def name
  @name
end

#namesObject

Returns the value of attribute names.



38
39
40
# File 'lib/pokeapi_client/models/item_detail.rb', line 38

def names
  @names
end

#spritesObject

Returns the value of attribute sprites.



42
43
44
# File 'lib/pokeapi_client/models/item_detail.rb', line 42

def sprites
  @sprites
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



70
71
72
# File 'lib/pokeapi_client/models/item_detail.rb', line 70

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



75
76
77
# File 'lib/pokeapi_client/models/item_detail.rb', line 75

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/pokeapi_client/models/item_detail.rb', line 49

def self.attribute_map
  {
    :'id' => :'id',
    :'name' => :'name',
    :'cost' => :'cost',
    :'fling_power' => :'fling_power',
    :'fling_effect' => :'fling_effect',
    :'attributes' => :'attributes',
    :'category' => :'category',
    :'effect_entries' => :'effect_entries',
    :'flavor_text_entries' => :'flavor_text_entries',
    :'game_indices' => :'game_indices',
    :'names' => :'names',
    :'held_by_pokemon' => :'held_by_pokemon',
    :'sprites' => :'sprites',
    :'baby_trigger_for' => :'baby_trigger_for',
    :'machines' => :'machines'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
# File 'lib/pokeapi_client/models/item_detail.rb', line 481

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_nullableObject

List of attributes with nullable: true



101
102
103
104
105
106
# File 'lib/pokeapi_client/models/item_detail.rb', line 101

def self.openapi_nullable
  Set.new([
    :'cost',
    :'fling_power',
  ])
end

.openapi_typesObject

Attribute type mapping.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/pokeapi_client/models/item_detail.rb', line 80

def self.openapi_types
  {
    :'id' => :'Integer',
    :'name' => :'String',
    :'cost' => :'Integer',
    :'fling_power' => :'Integer',
    :'fling_effect' => :'ItemFlingEffectSummary',
    :'attributes' => :'Array<AbilityDetailPokemonInnerPokemon>',
    :'category' => :'ItemCategorySummary',
    :'effect_entries' => :'Array<ItemEffectText>',
    :'flavor_text_entries' => :'Array<ItemFlavorText>',
    :'game_indices' => :'Array<ItemGameIndex>',
    :'names' => :'Array<ItemName>',
    :'held_by_pokemon' => :'Array<ItemDetailHeldByPokemonInner>',
    :'sprites' => :'ItemDetailSprites',
    :'baby_trigger_for' => :'ItemDetailBabyTriggerFor',
    :'machines' => :'Array<ItemDetailMachinesInner>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/pokeapi_client/models/item_detail.rb', line 446

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      name == o.name &&
      cost == o.cost &&
      fling_power == o.fling_power &&
      fling_effect == o.fling_effect &&
      attributes == o.attributes &&
      category == o.category &&
      effect_entries == o.effect_entries &&
      flavor_text_entries == o.flavor_text_entries &&
      game_indices == o.game_indices &&
      names == o.names &&
      held_by_pokemon == o.held_by_pokemon &&
      sprites == o.sprites &&
      baby_trigger_for == o.baby_trigger_for &&
      machines == o.machines
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


468
469
470
# File 'lib/pokeapi_client/models/item_detail.rb', line 468

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



474
475
476
# File 'lib/pokeapi_client/models/item_detail.rb', line 474

def hash
  [id, name, cost, fling_power, fling_effect, attributes, category, effect_entries, flavor_text_entries, game_indices, names, held_by_pokemon, sprites, baby_trigger_for, machines].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/pokeapi_client/models/item_detail.rb', line 227

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 @fling_effect.nil?
    invalid_properties.push('invalid value for "fling_effect", fling_effect cannot be nil.')
  end

  if @attributes.nil?
    invalid_properties.push('invalid value for "attributes", attributes cannot be nil.')
  end

  if @category.nil?
    invalid_properties.push('invalid value for "category", category cannot be nil.')
  end

  if @effect_entries.nil?
    invalid_properties.push('invalid value for "effect_entries", effect_entries cannot be nil.')
  end

  if @flavor_text_entries.nil?
    invalid_properties.push('invalid value for "flavor_text_entries", flavor_text_entries cannot be nil.')
  end

  if @game_indices.nil?
    invalid_properties.push('invalid value for "game_indices", game_indices cannot be nil.')
  end

  if @names.nil?
    invalid_properties.push('invalid value for "names", names cannot be nil.')
  end

  if @held_by_pokemon.nil?
    invalid_properties.push('invalid value for "held_by_pokemon", held_by_pokemon cannot be nil.')
  end

  if @sprites.nil?
    invalid_properties.push('invalid value for "sprites", sprites cannot be nil.')
  end

  if @baby_trigger_for.nil?
    invalid_properties.push('invalid value for "baby_trigger_for", baby_trigger_for cannot be nil.')
  end

  if @machines.nil?
    invalid_properties.push('invalid value for "machines", machines cannot be nil.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



503
504
505
506
507
508
509
510
511
512
513
514
515
# File 'lib/pokeapi_client/models/item_detail.rb', line 503

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

Returns:

  • (Boolean)

    true if the model is valid



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/pokeapi_client/models/item_detail.rb', line 291

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 @fling_effect.nil?
  return false if @attributes.nil?
  return false if @category.nil?
  return false if @effect_entries.nil?
  return false if @flavor_text_entries.nil?
  return false if @game_indices.nil?
  return false if @names.nil?
  return false if @held_by_pokemon.nil?
  return false if @sprites.nil?
  return false if @baby_trigger_for.nil?
  return false if @machines.nil?
  true
end