Class: Wot::Player::Tank

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Tank

Returns a new instance of Tank.



17
18
19
20
21
22
23
# File 'lib/wot/player/tank.rb', line 17

def initialize(data)
  @data = data
  @id = @data[:tank_id]
  @mark_of_mastery = @data[:mark_of_mastery]
  @battles = @data[:statistics][:battles]
  @wins = @data[:statistics][:wins]
end

Instance Attribute Details

#battlesObject

Returns the value of attribute battles.



6
7
8
# File 'lib/wot/player/tank.rb', line 6

def battles
  @battles
end

#dataObject

Returns the value of attribute data.



6
7
8
# File 'lib/wot/player/tank.rb', line 6

def data
  @data
end

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/wot/player/tank.rb', line 6

def id
  @id
end

#mark_of_masteryObject

Returns the value of attribute mark_of_mastery.



6
7
8
# File 'lib/wot/player/tank.rb', line 6

def mark_of_mastery
  @mark_of_mastery
end

#winsObject

Returns the value of attribute wins.



6
7
8
# File 'lib/wot/player/tank.rb', line 6

def wins
  @wins
end

Class Method Details

.get_tanks(player, api) ⇒ Object



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

def self.get_tanks(player,api)
  tanks = []
  response = api.player_tanks(player.id)
  response[:data][player.id.to_s].each do |item|
    tanks << Wot::Player::Tank.new(item)
  end
  return tanks
end