Class: Bnet::Starcraft2::Ladder
- Inherits:
-
BnetResource
- Object
- BnetResource
- Bnet::Starcraft2::Ladder
- Defined in:
- lib/bnet/starcraft2/ladder.rb
Constant Summary collapse
- PARAMS_MAPPING =
TODO make character object for :characters
{ "ladderName" => :ladder_name, "ladderId" => :ladder_id, "division" => :division, "rank" => :rank, "league" => :league, "matchMakingQueue" => :matchmaking_queue, "wins" => :wins, "losses" => :losses }
Instance Attribute Summary collapse
-
#characters ⇒ Object
Returns the value of attribute characters.
-
#division ⇒ Object
Returns the value of attribute division.
-
#ladder_id ⇒ Object
Returns the value of attribute ladder_id.
-
#ladder_name ⇒ Object
Returns the value of attribute ladder_name.
-
#league ⇒ Object
Returns the value of attribute league.
-
#losses ⇒ Object
Returns the value of attribute losses.
-
#matchmaking_queue ⇒ Object
Returns the value of attribute matchmaking_queue.
-
#rank ⇒ Object
Returns the value of attribute rank.
-
#raw_attributes ⇒ Object
Returns the value of attribute raw_attributes.
-
#wins ⇒ Object
Returns the value of attribute wins.
Class Method Summary collapse
Methods inherited from BnetResource
Constructor Details
This class inherits a constructor from Bnet::BnetResource
Instance Attribute Details
#characters ⇒ Object
Returns the value of attribute characters.
2 3 4 |
# File 'lib/bnet/starcraft2/ladder.rb', line 2 def characters @characters end |
#division ⇒ Object
Returns the value of attribute division.
2 3 4 |
# File 'lib/bnet/starcraft2/ladder.rb', line 2 def division @division end |
#ladder_id ⇒ Object
Returns the value of attribute ladder_id.
2 3 4 |
# File 'lib/bnet/starcraft2/ladder.rb', line 2 def ladder_id @ladder_id end |
#ladder_name ⇒ Object
Returns the value of attribute ladder_name.
2 3 4 |
# File 'lib/bnet/starcraft2/ladder.rb', line 2 def ladder_name @ladder_name end |
#league ⇒ Object
Returns the value of attribute league.
2 3 4 |
# File 'lib/bnet/starcraft2/ladder.rb', line 2 def league @league end |
#losses ⇒ Object
Returns the value of attribute losses.
2 3 4 |
# File 'lib/bnet/starcraft2/ladder.rb', line 2 def losses @losses end |
#matchmaking_queue ⇒ Object
Returns the value of attribute matchmaking_queue.
2 3 4 |
# File 'lib/bnet/starcraft2/ladder.rb', line 2 def matchmaking_queue @matchmaking_queue end |
#rank ⇒ Object
Returns the value of attribute rank.
2 3 4 |
# File 'lib/bnet/starcraft2/ladder.rb', line 2 def rank @rank end |
#raw_attributes ⇒ Object
Returns the value of attribute raw_attributes.
2 3 4 |
# File 'lib/bnet/starcraft2/ladder.rb', line 2 def raw_attributes @raw_attributes end |
#wins ⇒ Object
Returns the value of attribute wins.
2 3 4 |
# File 'lib/bnet/starcraft2/ladder.rb', line 2 def wins @wins end |
Class Method Details
.find_current(profile, args = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/bnet/starcraft2/ladder.rb', line 18 def self.find_current(profile, args = {}) profile_id = profile.profile_id name = profile.name realm = profile.realm || '1' locale = args[:locale] || 'en_US' api_key = args[:api_key] || Bnet.configuration.api_key client = Bnet::Starcraft2.new(region: profile.region) call_url = client.url + "profile/#{profile_id}/#{realm}/#{name}/ladders?apikey=#{api_key}&locale=#{locale}" begin data = open(call_url) raw_collection_response = JSON.parse(data.read) if Bnet::API.valid_call?(data.status, raw_collection_response) ladders = collection_from_api(raw_collection_response["currentSeason"]) else ladders = [] end rescue OpenURI::HTTPError => e ladders = [] end return ladders end |
.find_previous(profile, args = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/bnet/starcraft2/ladder.rb', line 46 def self.find_previous(profile, args ={} ) profile_id = profile.profile_id name = profile.name realm = profile.realm || '1' locale = args[:locale] || 'en_US' api_key = args[:api_key] || Bnet.configuration.api_key client = Bnet::Starcraft2.new(region: profile.region) call_url = client.url + "profile/#{profile_id}/#{realm}/#{name}/ladders?apikey=#{api_key}&locale=#{locale}" begin data = open(call_url) raw_collection_response = JSON.parse(data.read) if Bnet::API.valid_call?(data.status, raw_collection_response) ladders = collection_from_api(raw_collection_response["previousSeason"]) else ladders = [] end rescue OpenURI::HTTPError => e ladders = [] end return ladders end |