class Oakdex::Pokedex::Pokemon
Represents the Pokemon
Public Class Methods
add_to_all(custom_entries)
click to toggle source
Calls superclass method
Oakdex::Pokedex::Base::add_to_all
# 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()
click to toggle source
# 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)
click to toggle source
# File lib/oakdex/pokedex/pokemon.rb, line 47 def find(name) all[name] || all_by_id[name] end
import!(custom_pokemon)
click to toggle source
# File lib/oakdex/pokedex/pokemon.rb, line 32 def import!(custom_pokemon) PokemonImporter.new(custom_pokemon).import! end
where(conditions = {})
click to toggle source
Calls superclass method
Oakdex::Pokedex::Base::where
# 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
Private Class Methods
by_dex(dex)
click to toggle source
# File lib/oakdex/pokedex/pokemon.rb, line 62 def by_dex(dex) all.values.select do |entry| !entry.public_send("#{dex}_id").nil? end.sort_by(&:"#{dex}_id") end
Public Instance Methods
learnset()
click to toggle source
# File lib/oakdex/pokedex/pokemon.rb, line 13 def learnset move_learnsets.last['learnset'] end
locations()
click to toggle source
# 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