class SteamStoreParser::Parser

Constants

CONTAINER_CSS
PAGE_AMOUNT_CSS

Public Class Methods

new(params) click to toggle source
# File lib/steam-store-parser/parser.rb, line 7
def initialize(params)
  @base_client = BaseClient.new(params)
end

Public Instance Methods

games() click to toggle source
# File lib/steam-store-parser/parser.rb, line 11
def games
  @pages_nb = page_amount
  parse_games
end

Private Instance Methods

page_amount() click to toggle source
# File lib/steam-store-parser/parser.rb, line 17
def page_amount
  home_page = Nokogiri::HTML(@base_client.home_page)
  home_page.css(PAGE_AMOUNT_CSS)[2].text.to_i
end
parse_games() click to toggle source
# File lib/steam-store-parser/parser.rb, line 22
def parse_games
  @pages_nb.times.flat_map do |page_nb|
    page = Nokogiri::HTML(@base_client.page(page_nb))
    page.css(CONTAINER_CSS)[1].css('a').map do |item|
      Game.new(item.css('.title').text, item['data-ds-appid'])
    end
  end
end