Class: Wot::Player::Info
- Inherits:
-
Object
- Object
- Wot::Player::Info
- Defined in:
- lib/wot/player/info.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#data ⇒ Object
Returns the value of attribute data.
-
#player ⇒ Object
Returns the value of attribute player.
Instance Method Summary collapse
-
#initialize(player, api) ⇒ Info
constructor
A new instance of Info.
- #statistics ⇒ Object
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
#api ⇒ Object
Returns the value of attribute api.
5 6 7 |
# File 'lib/wot/player/info.rb', line 5 def api @api end |
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'lib/wot/player/info.rb', line 5 def data @data end |
#player ⇒ Object
Returns the value of attribute player.
5 6 7 |
# File 'lib/wot/player/info.rb', line 5 def player @player end |
Instance Method Details
#statistics ⇒ Object
17 18 19 20 |
# File 'lib/wot/player/info.rb', line 17 def statistics @statistics ||= Wot::Player::Statistics.new(@data[:statistics]) return @statistics end |