Class: Clashinator::Player
Overview
This class represents the player model
Constant Summary
Constants inherited from Base
Base::CLASS_MAP, Base::OBJECT_MAP
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Player
constructor
A new instance of Player.
Methods inherited from Base
prepare_options, #verify_array_of_classes, #verify_hash_that_are_objects
Methods included from Camelizable
Methods included from Underscorable
Constructor Details
#initialize(attrs) ⇒ Player
Returns a new instance of Player.
4 5 6 |
# File 'lib/clashinator/player.rb', line 4 def initialize(attrs) super(attrs) end |
Class Method Details
.player_info(http, player_tag) ⇒ Object
8 9 10 11 12 13 14 15 |
# 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 |