Class: Starcraft2::Client
- Inherits:
-
Object
- Object
- Starcraft2::Client
- Defined in:
- lib/starcraft2/client.rb
Constant Summary collapse
- ACHIEVEMENTS_PATH =
'/api/sc2/data/achievements'
- REWARDS_PATH =
'/api/sc2/data/rewards'
- LADDER_PATH =
'/api/sc2/ladder/'
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#locale ⇒ Object
Returns the value of attribute locale.
Instance Method Summary collapse
- #achievements ⇒ Object
- #flush_cache ⇒ Object
- #grandmaster_ladder ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #ladder(id) ⇒ Object
- #last_grandmaster_ladder ⇒ Object
- #profile(options = {}) ⇒ Object
- #rewards ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 |
# File 'lib/starcraft2/client.rb', line 9 def initialize( = {}) .each do |k, v| self.send(:"#{k}=", v) end self.host = 'us.battle.net' if self.host.nil? end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
7 8 9 |
# File 'lib/starcraft2/client.rb', line 7 def host @host end |
#locale ⇒ Object
Returns the value of attribute locale.
7 8 9 |
# File 'lib/starcraft2/client.rb', line 7 def locale @locale end |
Instance Method Details
#achievements ⇒ Object
25 26 27 |
# File 'lib/starcraft2/client.rb', line 25 def achievements Achievement.build(achievements_data) end |
#flush_cache ⇒ Object
45 46 47 |
# File 'lib/starcraft2/client.rb', line 45 def flush_cache @memoizations = {} end |
#grandmaster_ladder ⇒ Object
37 38 39 |
# File 'lib/starcraft2/client.rb', line 37 def grandmaster_ladder ladder('grandmaster') end |
#ladder(id) ⇒ Object
33 34 35 |
# File 'lib/starcraft2/client.rb', line 33 def ladder(id) Ladder.build(ladder_data(id)) end |
#last_grandmaster_ladder ⇒ Object
41 42 43 |
# File 'lib/starcraft2/client.rb', line 41 def last_grandmaster_ladder ladder('grandmaster/last') end |
#profile(options = {}) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/starcraft2/client.rb', line 17 def profile( = {}) if (args = [:character_name, :id, :realm] - .keys).empty? Profile.build(self, profile_data()) else raise MissingArgumentsError, "Missing Keys: #{args.map { |i| ":#{i}" }.join(', ')}" end end |