Class: Lol::ChampionRequest

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

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, #api_url, #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_versionString

Returns the supported API Version

Returns:

  • (String)

    the supported api version



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

def self.api_version
  "v1.2"
end

Instance Method Details

#get(options = {}) ⇒ Array

Retrieve all champions

Parameters:

  • options (Hash) (defaults to: {})

    the options to pass to the call

Options Hash (options):

  • :id (Fixnum)

    the champion to get. If nil gets all champions

  • :free_to_play (Boolean)

    filters for free to play champions

Returns:

  • (Array)

    an array of champions



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lol/champion_request.rb', line 14

def get options = {}

  champion_id = options.delete :id
  free_to_play = options.delete(:free_to_play) ? true : false

  url = champion_id ? "champion/#{champion_id}" : "champion"
  result = perform_request(api_url(url, "freeToPlay" => free_to_play))

  if champion_id
    Champion.new(result)
  else
    result["champions"].map {|c| Champion.new(c)}
  end
end