Class: Stew::Store::StoreClient
- Inherits:
-
Object
- Object
- Stew::Store::StoreClient
- Defined in:
- lib/stew/store/store_client.rb
Overview
Creation of app objects from URLs or app_ids
Can create apps for any steam region. When no region is given, it defaults to the default region in the configuration
Constant Summary collapse
- STORE_URL =
'http://store.steampowered.com'
Instance Method Summary collapse
- #app(app_id, region = Stew.config[:default_region]) ⇒ Object
- #create_app(data) ⇒ Object
-
#initialize(opts = {}) ⇒ StoreClient
constructor
A new instance of StoreClient.
Constructor Details
#initialize(opts = {}) ⇒ StoreClient
Returns a new instance of StoreClient.
22 23 24 |
# File 'lib/stew/store/store_client.rb', line 22 def initialize(opts = {}) @client = opts[:client] || Stew.config[:default_web_client].new(STORE_URL) end |
Instance Method Details
#app(app_id, region = Stew.config[:default_region]) ⇒ Object
33 34 35 |
# File 'lib/stew/store/store_client.rb', line 33 def app(app_id,region = Stew.config[:default_region]) Store::App.new(@client.get("/app/#{app_id}",:cc => region.to_sym), app_id.to_i) end |
#create_app(data) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/stew/store/store_client.rb', line 26 def create_app(data) return app(data) if data.class == Fixnum return app($1,$2) if data =~ /store.steampowered.com\/app\/([0-9]+)\/?\?cc=([a-zA-Z]{2})/ return app($1) if data =~ /store.steampowered.com\/app\/([0-9]+)/ raise AppIdNotFoundError end |