Sha256: 3060b6680f73663d9d7b7bdd76fadba0236610d9d0305281a6d958db9e963f19
Contents?: true
Size: 1.89 KB
Versions: 2
Compression:
Stored size: 1.89 KB
Contents
module Lol class SummonerRequest < Request # Returns the supported API Version # @return [String] the supported api version def self.api_version "v1.3" end # Looks for a summoner name and returns the associated summoner # @param [Array] summoner names # @return [Array] matching summoners def by_name *names perform_request(api_url("summoner/by-name/#{names.join(",")}")).map do |key, data| Summoner.new data end end # Get list of summoner names by summoner IDs # @param [Array] summoner_ids # @return [Hash] Hash in the form { "id" => "name" } def name *summoner_ids perform_request(api_url("summoner/#{summoner_ids.join(",")}/name")) end # Get a list of summoners by summoner ID # @param [Array] summoner_ids # @return [Array] matching summoners def get *summoner_ids perform_request(api_url("summoner/#{summoner_ids.join(",")}")).map do |key, data| Summoner.new data end end # Get rune pages by summoner ID # @param [Array] summoner_ids # @return [Array] array of Lol::RunePage def runes *summoner_ids extract_pages RunePage, "runes", summoner_ids end # Get mastery pages by summoner ID # @param [Array] summoner_ids # @return [Array] array of Lol::MasteryPage def masteries *summoner_ids extract_pages MasteryPage, "masteries", summoner_ids end private # Extract pages by summoner ID # @param klass [Class] class used to instance objects in arrays # @param page_type [String] path of the request # @param *summoner_ids [Array] array of summoner_ids def extract_pages klass, page_type, *summoner_ids perform_request(api_url("summoner/#{summoner_ids.join(",")}/#{page_type}")).inject({}) do |ack, data| ack[data.first] = data.last["pages"].map {|m| klass.new m} ack end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-lol-0.9.8 | lib/lol/summoner_request.rb |
ruby-lol-0.9.7 | lib/lol/summoner_request.rb |