Class: XboxLive::ProfilePage
- Inherits:
-
Object
- Object
- XboxLive::ProfilePage
- Defined in:
- lib/xbox_live/profile_page.rb
Overview
Each ProfilePage tracks and makes available the data contained in an Xbox Live profile web page. This can be used to determine general information about a payer, such as their total score, avatar picture, or bio.
Instance Attribute Summary collapse
-
#avatar ⇒ Object
Returns the value of attribute avatar.
-
#bio ⇒ Object
Returns the value of attribute bio.
-
#gamerscore ⇒ Object
Returns the value of attribute gamerscore.
-
#gamertag ⇒ Object
Returns the value of attribute gamertag.
-
#gamertile_small ⇒ Object
Returns the value of attribute gamertile_small.
-
#motto ⇒ Object
Returns the value of attribute motto.
-
#nickname ⇒ Object
Returns the value of attribute nickname.
-
#page ⇒ Object
Returns the value of attribute page.
-
#presence ⇒ Object
Returns the value of attribute presence.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(gamertag) ⇒ ProfilePage
constructor
Create a new ProfilePage for the provided gamertag.
-
#refresh ⇒ Object
Force a reload of the ProfilePage data from the Xbox Live web site.
Constructor Details
#initialize(gamertag) ⇒ ProfilePage
Create a new ProfilePage for the provided gamertag. Retrieve the html profile page from the Xbox Live web site for analysis.
16 17 18 19 |
# File 'lib/xbox_live/profile_page.rb', line 16 def initialize(gamertag) @gamertag = gamertag refresh end |
Instance Attribute Details
#avatar ⇒ Object
Returns the value of attribute avatar.
10 11 12 |
# File 'lib/xbox_live/profile_page.rb', line 10 def avatar @avatar end |
#bio ⇒ Object
Returns the value of attribute bio.
10 11 12 |
# File 'lib/xbox_live/profile_page.rb', line 10 def bio @bio end |
#gamerscore ⇒ Object
Returns the value of attribute gamerscore.
10 11 12 |
# File 'lib/xbox_live/profile_page.rb', line 10 def gamerscore @gamerscore end |
#gamertag ⇒ Object
Returns the value of attribute gamertag.
10 11 12 |
# File 'lib/xbox_live/profile_page.rb', line 10 def gamertag @gamertag end |
#gamertile_small ⇒ Object
Returns the value of attribute gamertile_small.
10 11 12 |
# File 'lib/xbox_live/profile_page.rb', line 10 def gamertile_small @gamertile_small end |
#motto ⇒ Object
Returns the value of attribute motto.
10 11 12 |
# File 'lib/xbox_live/profile_page.rb', line 10 def motto @motto end |
#nickname ⇒ Object
Returns the value of attribute nickname.
10 11 12 |
# File 'lib/xbox_live/profile_page.rb', line 10 def nickname @nickname end |
#page ⇒ Object
Returns the value of attribute page.
10 11 12 |
# File 'lib/xbox_live/profile_page.rb', line 10 def page @page end |
#presence ⇒ Object
Returns the value of attribute presence.
10 11 12 |
# File 'lib/xbox_live/profile_page.rb', line 10 def presence @presence end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
10 11 12 |
# File 'lib/xbox_live/profile_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/profile_page.rb', line 10 def url @url end |
Instance Method Details
#refresh ⇒ Object
Force a reload of the ProfilePage data from the Xbox Live web site.
TODO: Parse the Location: and reputation fields as well.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/xbox_live/profile_page.rb', line 25 def refresh url = XboxLive.[:url_prefix] + '/en-US/Profile?' + Mechanize::Util.build_query_string(gamertag: @gamertag) @page = XboxLive::Scraper::get_page url return false if @page.nil? @url = url @updated_at = Time.now @gamerscore = find_gamerscore @motto = find_motto @avatar = find_avatar @nickname = find_nickname @bio = find_bio @presence = find_presence @gamertile_small = find_gamertile_small return true end |