Class: SteamClient::Profile

Inherits:
Object
  • Object
show all
Defined in:
lib/steam-client/profile.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(steamID64 = nil) ⇒ Profile

Returns a new instance of Profile.



23
24
25
26
27
# File 'lib/steam-client/profile.rb', line 23

def initialize(steamID64 = nil)
  self.steamID64 = steamID64
  @friends = []
  @games = []
end

Instance Attribute Details

#avatarFullObject

Returns the value of attribute avatarFull.



21
22
23
# File 'lib/steam-client/profile.rb', line 21

def avatarFull
  @avatarFull
end

#avatarIconObject

Returns the value of attribute avatarIcon.



21
22
23
# File 'lib/steam-client/profile.rb', line 21

def avatarIcon
  @avatarIcon
end

#avatarMediumObject

Returns the value of attribute avatarMedium.



21
22
23
# File 'lib/steam-client/profile.rb', line 21

def avatarMedium
  @avatarMedium
end

#customURLObject

Returns the value of attribute customURL.



21
22
23
# File 'lib/steam-client/profile.rb', line 21

def customURL
  @customURL
end

#friendsObject

Returns the value of attribute friends.



21
22
23
# File 'lib/steam-client/profile.rb', line 21

def friends
  @friends
end

#gamesObject

Returns the value of attribute games.



21
22
23
# File 'lib/steam-client/profile.rb', line 21

def games
  @games
end

#hoursPlayed2WkObject

Returns the value of attribute hoursPlayed2Wk.



21
22
23
# File 'lib/steam-client/profile.rb', line 21

def hoursPlayed2Wk
  @hoursPlayed2Wk
end

#locationObject

Returns the value of attribute location.



21
22
23
# File 'lib/steam-client/profile.rb', line 21

def location
  @location
end

#onlineStateObject

Returns the value of attribute onlineState.



21
22
23
# File 'lib/steam-client/profile.rb', line 21

def onlineState
  @onlineState
end

#realnameObject

Returns the value of attribute realname.



21
22
23
# File 'lib/steam-client/profile.rb', line 21

def realname
  @realname
end

#steamIDObject

Returns the value of attribute steamID.



21
22
23
# File 'lib/steam-client/profile.rb', line 21

def steamID
  @steamID
end

#steamID64Object

Returns the value of attribute steamID64.



21
22
23
# File 'lib/steam-client/profile.rb', line 21

def steamID64
  @steamID64
end

Class Method Details

.from_xml(xml) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/steam-client/profile.rb', line 29

def self.from_xml(xml)
  p = Crack::XML.parse(xml)

  if p.has_key? 'response' and p['response'].has_key? 'error'
  	raise SteamClient::Error::ProfileNotFound
  end

  profile = Profile.new
  
  profile.steamID = p['profile']['steamID']
  profile.steamID64 = p['profile']['steamID64']
  profile.avatarIcon = p['profile']['avatarIcon']
  profile.avatarMedium = p['profile']['avatarMedium']
  profile.avatarFull = p['profile']['avatarFull']
  profile.customURL = p['profile']['customURL']
  profile.hoursPlayed2Wk = p['profile']['hoursPlayed2Wk'].to_f
  profile.location = p['profile']['location']
  profile.realname = p['profile']['realname']
  profile.friends = []
  profile.games = []

  case p['profile']['onlineState']
  when 'online'
  	profile.onlineState = SteamClient::OnlineState::ONLINE
  when 'offline'
  	profile.onlineState = SteamClient::OnlineState::OFFLINE
  else
  	profile.onlineState = SteamClient::OnlineState::UNKNOWN
  end
  return profile
end