Class: XboxLive::ProfilePage

Inherits:
Object
  • Object
show all
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.

Example: live.xbox.com/en-US/Profile?Gamertag=someone

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#avatarObject

Returns the value of attribute avatar.



10
11
12
# File 'lib/xbox_live/profile_page.rb', line 10

def avatar
  @avatar
end

#bioObject

Returns the value of attribute bio.



10
11
12
# File 'lib/xbox_live/profile_page.rb', line 10

def bio
  @bio
end

#gamerscoreObject

Returns the value of attribute gamerscore.



10
11
12
# File 'lib/xbox_live/profile_page.rb', line 10

def gamerscore
  @gamerscore
end

#gamertagObject

Returns the value of attribute gamertag.



10
11
12
# File 'lib/xbox_live/profile_page.rb', line 10

def gamertag
  @gamertag
end

#gamertile_smallObject

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

#mottoObject

Returns the value of attribute motto.



10
11
12
# File 'lib/xbox_live/profile_page.rb', line 10

def motto
  @motto
end

#nicknameObject

Returns the value of attribute nickname.



10
11
12
# File 'lib/xbox_live/profile_page.rb', line 10

def nickname
  @nickname
end

#pageObject

Returns the value of attribute page.



10
11
12
# File 'lib/xbox_live/profile_page.rb', line 10

def page
  @page
end

#presenceObject

Returns the value of attribute presence.



10
11
12
# File 'lib/xbox_live/profile_page.rb', line 10

def presence
  @presence
end

#updated_atObject

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

#urlObject

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

#refreshObject

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.options[: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