Class: Skyhook::Core

Inherits:
Configuration show all
Defined in:
lib/skyhook/core.rb

Direct Known Subclasses

Game, User

Defined Under Namespace

Modules: IPlayerService, ISteamApps, ISteamEconomy, ISteamNews, ISteamRemoteStorage, ISteamUser, ISteamUserStats

Constant Summary

Constants inherited from Configuration

Skyhook::Configuration::BASE, Skyhook::Configuration::FORMATS

Class Method Summary collapse

Methods inherited from Configuration

configure

Class Method Details

.api_referenceObject



4
5
6
# File 'lib/skyhook/core.rb', line 4

def self.api_reference
  request '/ISteamWebAPIUtil/GetSupportedAPIList/v1/'
end

.get_method(method_name) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/skyhook/core.rb', line 8

def self.get_method(method_name)
  api_reference['apilist']['interfaces'].each do |interface|

    if meth = interface['methods'].find { |method|method['name'] == method_name }
      meth['interface'] = interface['name']
      return meth
    else
      nil
    end
  end
end

.method_missing(m, params = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/skyhook/core.rb', line 20

def self.method_missing(m, params = {})
  if method = get_method( m.to_s.camelize )
    url = "/#{ method['interface'] }/#{ method['name'] }/v#{ method['version'] }/"

    self.class.class_eval do
      define_method m do |params|
        request( "#{url}", params )
      end
    end

    send(m, params)
  else
    super
  end
end