Class: Pokeedex::Pokemon::Scrapper::Pokedex

Inherits:
Base
  • Object
show all
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

Base::BASE_URI

Instance Attribute Summary collapse

Instance Method Summary collapse

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_nameObject (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

#crawlHash

Crawl the Pokemon data from the Pokemon website

Returns:

  • (Hash)


30
31
32
# File 'lib/pokeedex/pokemon/scrapper/pokedex.rb', line 30

def crawl
  parser.as_json
end

#urlString

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

Returns:

  • (String)


23
24
25
# File 'lib/pokeedex/pokemon/scrapper/pokedex.rb', line 23

def url
  "#{BASE_URI}/#{number_or_name}"
end