Class: GameScraper

Inherits:
Object
  • Object
show all
Defined in:
lib/game_gem/gamescraper.rb

Instance Method Summary collapse

Constructor Details

#initializeGameScraper

Returns a new instance of GameScraper.



3
4
5
6
# File 'lib/game_gem/gamescraper.rb', line 3

def initialize
  @html = Nokogiri::HTML(open("http://store.steampowered.com/"))
  @games_html = @html.css("#tab_topsellers_content a")
end

Instance Method Details

#runObject



8
9
10
11
12
13
14
15
# File 'lib/game_gem/gamescraper.rb', line 8

def run
  @games_html.map do |game|
    fields = {}
    fields[:name] = game.css(".tab_item_name").text
    fields[:price] = game.css(".discount_final_price").text
    fields
  end
end