Class: Pokeedex::Pokemon::Scrapper::Pokedex
- Defined in:
- lib/pokeedex/pokemon/scrapper/pokedex.rb
Overview
The Pokedex scrapper. It holds the methods to crawl the Pokedex data from the Pokemon website
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#number_or_name ⇒ Object
readonly
Find by number or name the Pokemon data from the Pokemon website.
Instance Method Summary collapse
-
#crawl ⇒ Hash
Crawl the Pokemon data from the Pokemon website.
-
#initialize(number_or_name:) ⇒ Pokedex
constructor
A new instance of Pokedex.
-
#url ⇒ String
Return the URL to crawl the Pokemon data If you number_or_name is ‘pikachu’ then the URL will be ‘www.pokemon.com/el/pokedex/pikachu’.
Constructor Details
#initialize(number_or_name:) ⇒ Pokedex
Returns a new instance of Pokedex.
15 16 17 |
# File 'lib/pokeedex/pokemon/scrapper/pokedex.rb', line 15 def initialize(number_or_name:) @number_or_name = number_or_name end |
Instance Attribute Details
#number_or_name ⇒ Object (readonly)
Find by number or name the Pokemon data from the Pokemon website
13 14 15 |
# File 'lib/pokeedex/pokemon/scrapper/pokedex.rb', line 13 def number_or_name @number_or_name end |
Instance Method Details
#crawl ⇒ Hash
Crawl the Pokemon data from the Pokemon website
30 31 32 |
# File 'lib/pokeedex/pokemon/scrapper/pokedex.rb', line 30 def crawl parser.as_json end |
#url ⇒ String
Return the URL to crawl the Pokemon data If you number_or_name is ‘pikachu’ then the URL will be ‘www.pokemon.com/el/pokedex/pikachu’
23 24 25 |
# File 'lib/pokeedex/pokemon/scrapper/pokedex.rb', line 23 def url "#{BASE_URI}/#{number_or_name}" end |