Class: PokeApiClient::MoveMeta

Inherits:
ApiModelBase show all
Defined in:
lib/pokeapi_client/models/move_meta.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 = {}) ⇒ MoveMeta

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
# File 'lib/pokeapi_client/models/move_meta.rb', line 106

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#ailmentObject

Returns the value of attribute ailment.



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

def ailment
  @ailment
end

#ailment_chanceObject

Returns the value of attribute ailment_chance.



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

def ailment_chance
  @ailment_chance
end

#categoryObject

Returns the value of attribute category.



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

def category
  @category
end

#crit_rateObject

Returns the value of attribute crit_rate.



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

def crit_rate
  @crit_rate
end

#drainObject

Returns the value of attribute drain.



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

def drain
  @drain
end

#flinch_chanceObject

Returns the value of attribute flinch_chance.



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

def flinch_chance
  @flinch_chance
end

#healingObject

Returns the value of attribute healing.



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

def healing
  @healing
end

#max_hitsObject

Returns the value of attribute max_hits.



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

def max_hits
  @max_hits
end

#max_turnsObject

Returns the value of attribute max_turns.



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

def max_turns
  @max_turns
end

#min_hitsObject

Returns the value of attribute min_hits.



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

def min_hits
  @min_hits
end

#min_turnsObject

Returns the value of attribute min_turns.



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

def min_turns
  @min_turns
end

#stat_chanceObject

Returns the value of attribute stat_chance.



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

def stat_chance
  @stat_chance
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



61
62
63
# File 'lib/pokeapi_client/models/move_meta.rb', line 61

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



66
67
68
# File 'lib/pokeapi_client/models/move_meta.rb', line 66

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/pokeapi_client/models/move_meta.rb', line 43

def self.attribute_map
  {
    :'ailment' => :'ailment',
    :'category' => :'category',
    :'min_hits' => :'min_hits',
    :'max_hits' => :'max_hits',
    :'min_turns' => :'min_turns',
    :'max_turns' => :'max_turns',
    :'drain' => :'drain',
    :'healing' => :'healing',
    :'crit_rate' => :'crit_rate',
    :'ailment_chance' => :'ailment_chance',
    :'flinch_chance' => :'flinch_chance',
    :'stat_chance' => :'stat_chance'
  }
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



252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/pokeapi_client/models/move_meta.rb', line 252

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



89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/pokeapi_client/models/move_meta.rb', line 89

def self.openapi_nullable
  Set.new([
    :'min_hits',
    :'max_hits',
    :'min_turns',
    :'max_turns',
    :'drain',
    :'healing',
    :'crit_rate',
    :'ailment_chance',
    :'flinch_chance',
    :'stat_chance'
  ])
end

.openapi_typesObject

Attribute type mapping.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/pokeapi_client/models/move_meta.rb', line 71

def self.openapi_types
  {
    :'ailment' => :'MoveMetaAilmentSummary',
    :'category' => :'MoveMetaCategorySummary',
    :'min_hits' => :'Integer',
    :'max_hits' => :'Integer',
    :'min_turns' => :'Integer',
    :'max_turns' => :'Integer',
    :'drain' => :'Integer',
    :'healing' => :'Integer',
    :'crit_rate' => :'Integer',
    :'ailment_chance' => :'Integer',
    :'flinch_chance' => :'Integer',
    :'stat_chance' => :'Integer'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/pokeapi_client/models/move_meta.rb', line 220

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      ailment == o.ailment &&
      category == o.category &&
      min_hits == o.min_hits &&
      max_hits == o.max_hits &&
      min_turns == o.min_turns &&
      max_turns == o.max_turns &&
      drain == o.drain &&
      healing == o.healing &&
      crit_rate == o.crit_rate &&
      ailment_chance == o.ailment_chance &&
      flinch_chance == o.flinch_chance &&
      stat_chance == o.stat_chance
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


239
240
241
# File 'lib/pokeapi_client/models/move_meta.rb', line 239

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



245
246
247
# File 'lib/pokeapi_client/models/move_meta.rb', line 245

def hash
  [ailment, category, min_hits, max_hits, min_turns, max_turns, drain, healing, crit_rate, ailment_chance, flinch_chance, stat_chance].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/pokeapi_client/models/move_meta.rb', line 175

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @ailment.nil?
    invalid_properties.push('invalid value for "ailment", ailment cannot be nil.')
  end

  if @category.nil?
    invalid_properties.push('invalid value for "category", category 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



274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/pokeapi_client/models/move_meta.rb', line 274

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



191
192
193
194
195
196
# File 'lib/pokeapi_client/models/move_meta.rb', line 191

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @ailment.nil?
  return false if @category.nil?
  true
end