Class: Stew::Community::SteamIdResolver
- Inherits:
-
Object
- Object
- Stew::Community::SteamIdResolver
- Defined in:
- lib/stew/community/steam_id_resolver.rb
Overview
Resolves steam ids from numbers, urls and vanity names
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(client = Stew.config[:default_community_client].new) ⇒ SteamIdResolver
constructor
A new instance of SteamIdResolver.
- #steam_id(data) ⇒ Object
Constructor Details
#initialize(client = Stew.config[:default_community_client].new) ⇒ SteamIdResolver
Returns a new instance of SteamIdResolver.
8 9 10 |
# File 'lib/stew/community/steam_id_resolver.rb', line 8 def initialize(client = Stew.config[:default_community_client].new) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/stew/community/steam_id_resolver.rb', line 6 def client @client end |
Instance Method Details
#steam_id(data) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/stew/community/steam_id_resolver.rb', line 12 def steam_id(data) data_string = data.to_s return data.to_i if /^[0-9]+$/ === data_string matches = (/steamcommunity.com\/(id|profiles|)\/([a-z0-9]+)/i).match(data_string) steam_id = steam_id_from_matches(data,matches) return steam_id unless steam_id.nil? raise Stew::Community::SteamIdNotFoundError end |