Class: Stew::Community::SteamId

Inherits:
Object
  • Object
show all
Defined in:
lib/stew/community/steam_id.rb

Overview

The base class for all Steam Ids. Has accessors for the base profile, games and friends of a Steam Id

Examples:

Create an instance from a 64-bit steam id

Stew::Community::SteamId.new(76561197992917668) #=> Stew::Community::SteamId

Create an instance from a community URL

Stew::Community::SteamId.create("http://steamcommunity.com/profiles/76561197992917668") #=> Stew::Community::SteamId

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, opts = {}) ⇒ SteamId

Returns a new instance of SteamId.



16
17
18
19
# File 'lib/stew/community/steam_id.rb', line 16

def initialize(data,opts={})
  @client = opts[:client] || Stew.config[:default_community_client].new
  @id = SteamIdResolver.new(@client).steam_id(data)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



14
15
16
# File 'lib/stew/community/steam_id.rb', line 14

def id
  @id
end

Instance Method Details

#friendsObject



29
30
31
# File 'lib/stew/community/steam_id.rb', line 29

def friends
  @friends ||= ProfileFriends.new @client.profile_friends(@id)
end

#gamesObject



25
26
27
# File 'lib/stew/community/steam_id.rb', line 25

def games
  @games ||= ProfileGames.new @client.profile_games(@id)
end

#profileObject



21
22
23
# File 'lib/stew/community/steam_id.rb', line 21

def profile
  @profile ||= Profile.new(@client.profile(@id))
end