Class: XboxLive::AchievementsPage
- Inherits:
-
Object
- Object
- XboxLive::AchievementsPage
- Defined in:
- lib/xbox_live/achievements_page.rb
Overview
Each AchievementsPage tracks and makes available the data contianed in an Xbox Live “Compare Game” page. This can be used to determine which achievements a player has unlocked in a game.
Example: live.xbox.com/en-US/Activity/Details?titleId=1161890128&compareTo=someone
Instance Attribute Summary collapse
-
#achievements ⇒ Object
Returns the value of attribute achievements.
-
#data ⇒ Object
Returns the value of attribute data.
-
#game_id ⇒ Object
Returns the value of attribute game_id.
-
#gamertag ⇒ Object
Returns the value of attribute gamertag.
-
#page ⇒ Object
Returns the value of attribute page.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(gamertag, game_id) ⇒ AchievementsPage
constructor
Create a new AchievementsPage for the provided gamertag.
-
#refresh ⇒ Object
Force a reload of the AchievementsPage data from the Xbox Live web site.
Constructor Details
#initialize(gamertag, game_id) ⇒ AchievementsPage
Create a new AchievementsPage for the provided gamertag. Retrieve the html compare achievements page from the Xbox Live web site for analysis. To prevent multiple instances for the same gamertag, this method is marked as private. The AchievementsPage.find() method should be used to find an existing instance or create a new one if needed.
18 19 20 21 22 |
# File 'lib/xbox_live/achievements_page.rb', line 18 def initialize(gamertag, game_id) @gamertag = gamertag @game_id = game_id refresh end |
Instance Attribute Details
#achievements ⇒ Object
Returns the value of attribute achievements.
10 11 12 |
# File 'lib/xbox_live/achievements_page.rb', line 10 def achievements @achievements end |
#data ⇒ Object
Returns the value of attribute data.
10 11 12 |
# File 'lib/xbox_live/achievements_page.rb', line 10 def data @data end |
#game_id ⇒ Object
Returns the value of attribute game_id.
10 11 12 |
# File 'lib/xbox_live/achievements_page.rb', line 10 def game_id @game_id end |
#gamertag ⇒ Object
Returns the value of attribute gamertag.
10 11 12 |
# File 'lib/xbox_live/achievements_page.rb', line 10 def gamertag @gamertag end |
#page ⇒ Object
Returns the value of attribute page.
10 11 12 |
# File 'lib/xbox_live/achievements_page.rb', line 10 def page @page end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
10 11 12 |
# File 'lib/xbox_live/achievements_page.rb', line 10 def updated_at @updated_at end |
#url ⇒ Object
Returns the value of attribute url.
10 11 12 |
# File 'lib/xbox_live/achievements_page.rb', line 10 def url @url end |
Instance Method Details
#refresh ⇒ Object
Force a reload of the AchievementsPage data from the Xbox Live web site.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/xbox_live/achievements_page.rb', line 26 def refresh url = XboxLive.[:url_prefix] + '/en-US/Activity/Details?' + Mechanize::Util.build_query_string(titleId: @game_id, compareTo: @gamertag) @page = XboxLive::Scraper::get_page url return false if page.nil? @url = url @updated_at = Time.now @data = retrieve_achievement_data @gamertag = find_gamertag @achievements = find_achievements true end |