Class: XboxLive::GamesPage

Inherits:
Object
  • Object
show all
Defined in:
lib/xbox_live/games_page.rb

Overview

Each GamesPage tracks the data contianed in an Xbox Live “Compare Games” page. This can be used to determine which games a player has played, and their score and number of achievements acquired in each game.

Example: live.xbox.com/en-US/Activity?compareTo=someone

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gamertag) ⇒ GamesPage

Create a new GamesPage for the provided gamertag. Retrieve the html game compare page from the Xbox Live web site for analysis.



17
18
19
20
# File 'lib/xbox_live/games_page.rb', line 17

def initialize(gamertag)
  @gamertag = gamertag
  refresh
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



11
12
13
# File 'lib/xbox_live/games_page.rb', line 11

def data
  @data
end

#gamerscoreObject

Returns the value of attribute gamerscore.



11
12
13
# File 'lib/xbox_live/games_page.rb', line 11

def gamerscore
  @gamerscore
end

#gamertagObject

Returns the value of attribute gamertag.



11
12
13
# File 'lib/xbox_live/games_page.rb', line 11

def gamertag
  @gamertag
end

#gamertile_largeObject

Returns the value of attribute gamertile_large.



11
12
13
# File 'lib/xbox_live/games_page.rb', line 11

def gamertile_large
  @gamertile_large
end

#gamesObject

Returns the value of attribute games.



11
12
13
# File 'lib/xbox_live/games_page.rb', line 11

def games
  @games
end

#pageObject

Returns the value of attribute page.



11
12
13
# File 'lib/xbox_live/games_page.rb', line 11

def page
  @page
end

#progressObject

Returns the value of attribute progress.



11
12
13
# File 'lib/xbox_live/games_page.rb', line 11

def progress
  @progress
end

#updated_atObject

Returns the value of attribute updated_at.



11
12
13
# File 'lib/xbox_live/games_page.rb', line 11

def updated_at
  @updated_at
end

#urlObject

Returns the value of attribute url.



11
12
13
# File 'lib/xbox_live/games_page.rb', line 11

def url
  @url
end

Instance Method Details

#refreshObject

Force a reload of the GamesPage data from the Xbox Live web site.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/xbox_live/games_page.rb', line 24

def refresh
  url = XboxLive.options[:url_prefix] + '/en-US/Activity?' +
    Mechanize::Util.build_query_string(compareTo: @gamertag)
  @page = XboxLive::Scraper::get_page(url)
  return false if page.nil?

  @url = url
  @updated_at = Time.now
  @data = retrieve_game_data
  @gamertag = find_gamertag
  @gamertile_large = find_gamertile_large
  @gamerscore = find_gamerscore
  @progress = find_progress
  @games = find_games

  return true
end