Class: Stew::Community::SteamId
- Inherits:
-
Object
- Object
- Stew::Community::SteamId
- 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
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #friends ⇒ Object
- #games ⇒ Object
-
#initialize(steam_id, opts = {}) ⇒ SteamId
constructor
A new instance of SteamId.
- #profile ⇒ Object
Constructor Details
#initialize(steam_id, opts = {}) ⇒ SteamId
Returns a new instance of SteamId.
23 24 25 26 |
# File 'lib/stew/community/steam_id.rb', line 23 def initialize(steam_id,opts={}) @id = steam_id @client = opts[:client] || self.class.(steam_id) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/stew/community/steam_id.rb', line 14 def id @id end |
Class Method Details
.create(data) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/stew/community/steam_id.rb', line 16 def self.create(data) return self.new($1.to_i) if data =~ /steamcommunity.com\/profiles\/([0-9]+)/ return self.new($1) if data =~ /steamcommunity.com\/id\/([a-zA-Z0-9]+)/ return self.new(data) if data.to_s.match /^[0-9A-Za-z]+$/ raise SteamIdNotFoundError end |
Instance Method Details
#friends ⇒ Object
36 37 38 |
# File 'lib/stew/community/steam_id.rb', line 36 def friends @friends ||= @client.profile_friends @id end |
#games ⇒ Object
32 33 34 |
# File 'lib/stew/community/steam_id.rb', line 32 def games @games ||= @client.profile_games @id end |
#profile ⇒ Object
28 29 30 |
# File 'lib/stew/community/steam_id.rb', line 28 def profile @profile ||= @client.profile @id end |