Class: Wot::Player::Info

Inherits:
Object
  • Object
show all
Defined in:
lib/wot/player/info.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(player, api) ⇒ Info

Returns a new instance of Info.



7
8
9
10
11
12
13
14
15
# File 'lib/wot/player/info.rb', line 7

def initialize(player, api)
  @player = player
  @api = api
  response = api.players_info(player.id)
  @data = response[:data][player.id.to_s]
  @data.each do |key,_|
    self.send key
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object (protected)



24
25
26
27
28
29
30
# File 'lib/wot/player/info.rb', line 24

def method_missing(method_name, *args, &block)
  self.class.instance_eval do
    define_method method_name do 
      return @data[method_name]
    end
  end
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



5
6
7
# File 'lib/wot/player/info.rb', line 5

def api
  @api
end

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/wot/player/info.rb', line 5

def data
  @data
end

#playerObject

Returns the value of attribute player.



5
6
7
# File 'lib/wot/player/info.rb', line 5

def player
  @player
end

Instance Method Details

#statisticsObject



17
18
19
20
# File 'lib/wot/player/info.rb', line 17

def statistics
  @statistics ||= Wot::Player::Statistics.new(@data[:statistics])
  return @statistics
end