class Dotka
Public Class Methods
new()
click to toggle source
# File lib/dotka.rb, line 8 def initialize @key = nil end
version()
click to toggle source
Rather than updating the gemspec every time.
# File lib/dotka.rb, line 57 def self.version "1.2.2" end
Public Instance Methods
get_api_key()
click to toggle source
# File lib/dotka.rb, line 16 def get_api_key @key end
match(id)
click to toggle source
# 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 = {})
click to toggle source
# 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)
click to toggle source
# File lib/dotka.rb, line 12 def set_api_key key @key = key end