Class: Dotka
- Inherits:
-
Object
- Object
- Dotka
- Defined in:
- lib/dotka.rb
Class Method Summary collapse
-
.version ⇒ Object
Rather than updating the gemspec every time.
Instance Method Summary collapse
- #get_api_key ⇒ Object
-
#initialize ⇒ Dotka
constructor
A new instance of Dotka.
- #match(id) ⇒ Object
- #matches(account_id, conditions = {}) ⇒ Object
- #set_api_key(key) ⇒ Object
Constructor Details
#initialize ⇒ Dotka
Returns a new instance of Dotka.
8 9 10 |
# File 'lib/dotka.rb', line 8 def initialize @key = nil end |
Class Method Details
.version ⇒ Object
Rather than updating the gemspec every time.
57 58 59 |
# File 'lib/dotka.rb', line 57 def self.version "1.2.2" end |
Instance Method Details
#get_api_key ⇒ Object
16 17 18 |
# File 'lib/dotka.rb', line 16 def get_api_key @key end |
#match(id) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dotka.rb', line 20 def match id raise "Please set up the API key!" unless not @key.nil? response = RestClient.get( "https://api.steampowered.com/IDOTA2Match_570/GetMatchDetails/V001", {"params" => {"key" => @key, "match_id" => id}} ) raise "Can not load a match with ID #{id}." unless response.code == 200 DotkaM::Match.new(JSON.parse(response.to_str)["result"]) end |
#matches(account_id, conditions = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dotka.rb', line 35 def matches account_id, conditions = {} raise "Please set up the API key!" unless not @key.nil? response = RestClient.get( "https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/V001", {"params" => {"key" => @key, "account_id" => account_id}.merge(conditions)} ) raise "Can not load matches for account ID #{account_id}." unless response.code == 200 matches = Array.new JSON.parse(response.to_str)["result"]["matches"].each { |match| matches.push DotkaM::Match.new(match) } matches end |
#set_api_key(key) ⇒ Object
12 13 14 |
# File 'lib/dotka.rb', line 12 def set_api_key key @key = key end |