Class: Oakdex::Pokedex::Pokemon
- Inherits:
-
Base
- Object
- Base
- Oakdex::Pokedex::Pokemon
show all
- Defined in:
- lib/oakdex/pokedex/pokemon.rb
Overview
Instance Attribute Summary
Attributes inherited from Base
#attributes
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
all, find!, #initialize, json_folder, #method_missing, reset!, #respond_to_missing?, translate
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Oakdex::Pokedex::Base
Class Method Details
.add_to_all(custom_entries) ⇒ Object
42
43
44
45
|
# File 'lib/oakdex/pokedex/pokemon.rb', line 42
def add_to_all(custom_entries)
@all_by_id = nil
super(custom_entries)
end
|
.all_by_id ⇒ Object
36
37
38
39
40
|
# File 'lib/oakdex/pokedex/pokemon.rb', line 36
def all_by_id
@all_by_id ||= Hash[all.map do |_k, pokemon|
[pokemon.national_id, pokemon]
end]
end
|
.find(name) ⇒ Object
47
48
49
|
# File 'lib/oakdex/pokedex/pokemon.rb', line 47
def find(name)
all[name] || all_by_id[name]
end
|
.import!(custom_pokemon) ⇒ Object
32
33
34
|
# File 'lib/oakdex/pokedex/pokemon.rb', line 32
def import!(custom_pokemon)
PokemonImporter.new(custom_pokemon).import!
end
|
.where(conditions = {}) ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/oakdex/pokedex/pokemon.rb', line 51
def where(conditions = {})
conditions[:types] = conditions.delete(:type) if conditions[:type]
if conditions[:egg_group]
conditions[:egg_groups] = conditions.delete(:egg_group)
end
return by_dex(conditions[:dex]) if conditions[:dex]
super(conditions)
end
|
Instance Method Details
#learnset ⇒ Object
13
14
15
|
# File 'lib/oakdex/pokedex/pokemon.rb', line 13
def learnset
move_learnsets.last['learnset']
end
|
#locations ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/oakdex/pokedex/pokemon.rb', line 17
def locations
Region.all.values.map do |region|
region.locations.map do |location|
location['pokemon'].map do |p|
next unless p['pokemon'] == name
p.merge(
'region' => region.name,
'location' => location['names']['en']
)
end.compact
end
end.flatten
end
|