Class: Lol::StaticRequest

Inherits:
Request
  • Object
show all
Defined in:
lib/lol/static_request.rb

Defined Under Namespace

Classes: Proxy

Constant Summary collapse

STANDARD_ENDPOINTS =
%w(champion item mastery rune summoner_spell)

Instance Attribute Summary

Attributes inherited from Request

#api_key, #cache_store, #region

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Request

#api_base_url, #api_query_string, #cached?, #clean_url, #initialize, #perform_request, #post_api_url, #store, #ttl

Constructor Details

This class inherits a constructor from Lol::Request

Class Method Details

.api_versionObject



5
6
7
# File 'lib/lol/static_request.rb', line 5

def self.api_version
  "v1.2"
end

Instance Method Details

#api_url(path, params = {}) ⇒ String

Returns a full url for an API call Overrides api_url from Request

Parameters:

  • path (String)

    API path to call

Returns:

  • (String)

    full fledged url



13
14
15
# File 'lib/lol/static_request.rb', line 13

def api_url path, params = {}
  super(path,params).gsub(/api\/lol/, "api/lol/static-data").gsub(/\/\/#{region}/, "//global")
end

#get(endpoint, id = nil, params = {}) ⇒ Object



29
30
31
32
# File 'lib/lol/static_request.rb', line 29

def get(endpoint, id=nil, params={})
  return perform_request(api_url("versions")).map {|x| x} if endpoint == "versions"
  id ? find(endpoint, id, params) : all(endpoint, params)
end

#realmObject



21
22
23
# File 'lib/lol/static_request.rb', line 21

def realm
  Proxy.new self, 'realm'
end

#versionsObject



25
26
27
# File 'lib/lol/static_request.rb', line 25

def versions
  Proxy.new self, 'versions'
end