Class: Wot::Player
- Inherits:
-
Object
- Object
- Wot::Player
- Defined in:
- lib/wot/player.rb,
lib/wot/player/info.rb,
lib/wot/player/tank.rb,
lib/wot/player/statistics.rb,
lib/wot/player/achievement.rb,
lib/wot/player/extended_statistics.rb
Defined Under Namespace
Classes: Achievement, ExtendedStatistics, Info, Statistics, Tank
Instance Attribute Summary collapse
-
#account_id ⇒ Object
Returns the value of attribute account_id.
-
#api ⇒ Object
Returns the value of attribute api.
-
#id ⇒ Object
Returns the value of attribute id.
-
#nickname ⇒ Object
Returns the value of attribute nickname.
Class Method Summary collapse
- .create_players_from_data(data, api) ⇒ Object
- .find(api, account_ids, options = {}) ⇒ Object
- .search(api, nickname, options = {}) ⇒ Object
Instance Method Summary collapse
- #achievements ⇒ Object
- #info ⇒ Object
-
#initialize(options, api) ⇒ Player
constructor
A new instance of Player.
- #tanks ⇒ Object
Constructor Details
#initialize(options, api) ⇒ Player
Returns a new instance of Player.
35 36 37 38 39 40 |
# File 'lib/wot/player.rb', line 35 def initialize(, api) @api = api @id = [:account_id] @account_id = @id @nickname = [:nickname] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object (private)
59 60 61 62 |
# File 'lib/wot/player.rb', line 59 def method_missing(method_name, *args, &block) info return @info.send method_name end |
Instance Attribute Details
#account_id ⇒ Object
Returns the value of attribute account_id.
8 9 10 |
# File 'lib/wot/player.rb', line 8 def account_id @account_id end |
#api ⇒ Object
Returns the value of attribute api.
8 9 10 |
# File 'lib/wot/player.rb', line 8 def api @api end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/wot/player.rb', line 8 def id @id end |
#nickname ⇒ Object
Returns the value of attribute nickname.
8 9 10 |
# File 'lib/wot/player.rb', line 8 def nickname @nickname end |
Class Method Details
.create_players_from_data(data, api) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/wot/player.rb', line 27 def self.create_players_from_data(data,api) players = [] data.each do |item| players << Wot::Player.new(item, api) end return players end |
.find(api, account_ids, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/wot/player.rb', line 17 def self.find(api, account_ids, = {}) parameters = { account_id: (account_ids.class == Array ? account_ids : [account_ids]), fields: 'account_id,nickname' } parameters = parameters.merge response = api.make_request 'account/info/', parameters return create_players_from_data response[:data].values, api end |
.search(api, nickname, options = {}) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/wot/player.rb', line 10 def self.search(api, nickname, = {}) parameters = {search: nickname} parameters = parameters.merge response = api.make_request 'account/list/', parameters return create_players_from_data response[:data], api end |
Instance Method Details
#achievements ⇒ Object
47 48 49 50 |
# File 'lib/wot/player.rb', line 47 def achievements @achievements ||= Wot::Player::Achievement.get_achievements(self,@api) return @achievements end |