class Clashinator::Player

This class represents the player model

Public Class Methods

new(attrs) click to toggle source
Calls superclass method Clashinator::Base::new
# File lib/clashinator/player.rb, line 4
def initialize(attrs)
  super(attrs)
end
player_info(http, player_tag) click to toggle source
# File lib/clashinator/player.rb, line 8
def self.player_info(http, player_tag)
  player_tag.gsub!('#', '%23')
  response = http.get("/v1/players/#{player_tag}")
  parsed = JSON.parse(response.body)

  return new(parsed) if response.success?
  raise parsed['reason'] unless response.success?
end