Class: Oakdex::Pokedex::PokemonImporter
- Inherits:
-
Object
- Object
- Oakdex::Pokedex::PokemonImporter
- Defined in:
- lib/oakdex/pokedex/pokemon_importer.rb
Overview
Handles Pokemon Import
Instance Method Summary collapse
- #import! ⇒ Object
-
#initialize(custom_pokemon) ⇒ PokemonImporter
constructor
A new instance of PokemonImporter.
Constructor Details
#initialize(custom_pokemon) ⇒ PokemonImporter
Returns a new instance of PokemonImporter.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/oakdex/pokedex/pokemon_importer.rb', line 7 def initialize(custom_pokemon) pokemon_list = if custom_pokemon.is_a?(Array) custom_pokemon else JSON.parse(custom_pokemon) end @pokemon = pokemon_list.map do |p| p.is_a?(Hash) ? p : JSON.parse(p) end end |
Instance Method Details
#import! ⇒ Object
18 19 20 21 |
# File 'lib/oakdex/pokedex/pokemon_importer.rb', line 18 def import! validate! Oakdex::Pokedex::Pokemon.add_to_all(@pokemon) end |