Class: PokeAPI
- Inherits:
-
Object
- Object
- PokeAPI
- Defined in:
- lib/poke_api.rb
Constant Summary collapse
- BASE_URL =
'http://pokeapi.co/api/v2/'
- RESOURCES =
[ 'ability', 'berry', 'berry_firmness', 'berry_flavor', 'characteristic', 'contest_effect', 'contest_type', 'egg_group', 'encounter_condition', 'encounter_condition_value', 'encounter_method', 'evolution_chain', 'evolution_trigger', 'gender', 'generation', 'growth_rate', 'item', 'item_attribute', 'item_category', 'item_fling_effect', 'item_pocket', 'language', 'location', 'location_area', 'move', 'move_ailment', 'move_battle_style', 'move_category', 'move_damage_class', 'move_learn_method', 'move_target', 'nature', 'pal_park_area', 'pokeathlon_stat', 'pokedex', 'pokemon', 'pokemon_color', 'pokemon_form', 'pokemon_shape', 'pokemon_species', 'region', 'stat', 'super_contest_effect', 'type', 'version', 'version_group' ]
Instance Method Summary collapse
-
#initialize(format = :json) ⇒ PokeAPI
constructor
A new instance of PokeAPI.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(format = :json) ⇒ PokeAPI
Returns a new instance of PokeAPI.
23 24 25 |
# File 'lib/poke_api.rb', line 23 def initialize(format = :json) @format = format end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/poke_api.rb', line 27 def method_missing(method, *args) if RESOURCES.include? method.to_s method = hyphenate(method.to_s) get(method.to_s, args[0], args[1]) end end |