Class: SteamMist::RequestUri
- Inherits:
-
Object
- Object
- SteamMist::RequestUri
- Extended by:
- Forwardable
- Defined in:
- lib/steam_mist/request_uri.rb
Overview
This represents a request that may be made to the steam api. It is mainly used for obtaining paths to request to.
Instance Attribute Summary collapse
-
#arguments ⇒ Enumerable
These are the arguments that will be passed for the request.
-
#domain ⇒ String
The domain to make the reuqest to.
-
#interface ⇒ String
This is the interface the request will be made to, like
ISteamUser
. -
#method ⇒ String
This is the method of the interface the request will be made to.
-
#version ⇒ Numeric
The version of the method to request.
Instance Method Summary collapse
-
#format_uri ⇒ URI
Takes the request data and formats it into an URI.
-
#initialize(options) ⇒ RequestUri
constructor
Initialize the request.
-
#to_s ⇒ String
Outputs a string version of the request.
Constructor Details
#initialize(options) ⇒ RequestUri
Initialize the request. Can take a hash. Options for the hash can be ‘:interface`, `:method`, `:version`, `:domain` and `:arguments`.
Anything else will cause an argument error. See the attributes for each respectively on what they’re for.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/steam_mist/request_uri.rb', line 40 def initialize() { :interface => "", :method => "", :arguments => {}, :version => 0, :domain => "api.steampowered.com" }.merge().each do |k, v| if respond_to? "#{k}=" send "#{k}=", v else raise ArgumentError, "don't know how to handle #{k}!" end end end |
Instance Attribute Details
#arguments ⇒ Enumerable
These are the arguments that will be passed for the request.
22 23 24 |
# File 'lib/steam_mist/request_uri.rb', line 22 def arguments @arguments end |
#domain ⇒ String
The domain to make the reuqest to.
32 33 34 |
# File 'lib/steam_mist/request_uri.rb', line 32 def domain @domain end |
#interface ⇒ String
This is the interface the request will be made to, like ISteamUser
.
12 13 14 |
# File 'lib/steam_mist/request_uri.rb', line 12 def interface @interface end |
#method ⇒ String
This is the method of the interface the request will be made to.
17 18 19 |
# File 'lib/steam_mist/request_uri.rb', line 17 def method @method end |
#version ⇒ Numeric
The version of the method to request.
27 28 29 |
# File 'lib/steam_mist/request_uri.rb', line 27 def version @version end |
Instance Method Details
#format_uri ⇒ URI
Takes the request data and formats it into an URI.
59 60 61 62 63 64 65 66 |
# File 'lib/steam_mist/request_uri.rb', line 59 def format_uri basic = "http://%s/%s/%s/v%04d" % [domain, interface, method, version] uri = URI(basic) uri.query = URI.encode_www_form(arguments) uri end |
#to_s ⇒ String
Outputs a string version of the request.
71 72 73 |
# File 'lib/steam_mist/request_uri.rb', line 71 def to_s format_uri.to_s end |