Class: Wot::Player::Achievement

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, current, max = nil) ⇒ Achievement

Returns a new instance of Achievement.



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

def initialize(name, current, max = nil)
  @name = name
  @current = current
  @max = max
end

Instance Attribute Details

#currentObject

Returns the value of attribute current.



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

def current
  @current
end

#maxObject

Returns the value of attribute max.



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

def max
  @max
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

Class Method Details

.get_achievements(player, api) ⇒ Object



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

def self.get_achievements(player,api)
  achievements = []
  response = api.player_achievements(player.id)
  data = response[:data][player.id.to_s]
  names = data[:achievements].keys + data[:max_series].keys
  names.each do |name|
    achievements << Wot::Player::Achievement.new(name,data[:achievements][name],data[:max_series][name])
  end
  return achievements
end