PokemonLookup
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file lib/pokemon_lookup
. To experiment with that code, run bin/console
for an interactive prompt.
Classroom example of a wrapper gem. Using OOP to wrap the PokéAPI at https://pokeapi.co/
Installation
Add this line to your application's Gemfile:
gem 'pokemon_lookup'
And then execute:
$ bundle
Or install it yourself as:
$ gem install pokemon_lookup
Usage
To see a list of Pokemon by id, try this code.
print "How many Pokemon would you like to see?: "
query_amount = gets.chomp
print "Which page would you like to see?: "
page = gets.chomp
Pokemon.print_list(page, query_amount)
page
is for pagination and has a default of 1query_amount
is the number of pokemon on a page and has a default of 20
To see an individual Pokemon, you can pass in the id or name of the Pokemon with the code below.
print "Type the name or id of the pokemon you want to see: "
pokemon_input = gets.chomp
pokemon = Pokemon.catch(pokemon_input)
pokemon.print_info
Methods on a Pokemon
raw_data
, returns all data from the PokéAPI request in rubyid
, returns PokéAPI reference idname
, returns name of the pokemonweight
, returns weight of the pokemontypes
, returns all types for this pokemonabilities
, returns all abilities for this pokemonmoves
, returns all moves for this pokemonstats
, returns all stats for this pokemon, includes the stat's name, effort and base statprint_types
, prints a formatted display of this pokemon's typesprint_abilities
, prints a formatted display of this pokemon's abilitiesprint_moves
, prints a formatted display of this pokemon's movesprint_stats
, prints a formatted display of this pokemon's statsprint_info
, prints all formatted information for a pokemon.
The formatted printing methods assume a terminal width of 60 columns, if you want to configure a different terminal width you can use the following code.
Pokemon.terminal_width # returns current terminal size configuration
Pokemon.terminal_width = 80 # new terminal size
License
The gem is available as open source under the terms of the MIT License.