class Brawlhalla::API::Player
Constants
- ATTRIBUTES
Attributes
clan[R]
legend_stats[R]
Public Class Methods
find(brawlhalla_id)
click to toggle source
# File lib/brawlhalla/api/player.rb, line 18 def self.find(brawlhalla_id) stats_json = API.client.stats(brawlhalla_id) new(stats_json) end
new(json)
click to toggle source
# File lib/brawlhalla/api/player.rb, line 24 def initialize(json) ATTRIBUTES.each do |attr| value = json[attr] value = value.to_i if attr.to_s.start_with?('damage') send("#{attr}=", value) end # Fix player name encoding @name = @name.encode('iso-8859-1') initialize_clan(json) initialize_legends(json) end
Public Instance Methods
ranking()
click to toggle source
# File lib/brawlhalla/api/player.rb, line 39 def ranking @ranking ||= Ranking.find(brawlhalla_id) end
Private Instance Methods
initialize_clan(json)
click to toggle source
# File lib/brawlhalla/api/player.rb, line 52 def initialize_clan(json) return unless json[:clan] @clan = Clan.new(json[:clan]) end
initialize_legends(json)
click to toggle source
# File lib/brawlhalla/api/player.rb, line 58 def initialize_legends(json) return unless json[:legends] @legend_stats = json[:legends].map { |legend_json| LegendStat.new(legend_json) } end
sanitalize_damage_values()
click to toggle source
For some odd reason the damage values come as strings instead of integers.
# File lib/brawlhalla/api/player.rb, line 46 def sanitalize_damage_values @damagebomb = @damagebomb.to_i @damagesidekick = @damagesidekick.to_i @damagespikeball = @damagespikeball.to_i end