Class: RUBG::Player
- Inherits:
-
RubgEndpoint
- Object
- RubgEndpoint
- RUBG::Player
- Defined in:
- lib/rubg/player.rb
Instance Attribute Summary collapse
-
#assets ⇒ Object
readonly
Returns the value of attribute assets.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#match_ids ⇒ Object
readonly
Returns the value of attribute match_ids.
-
#matches ⇒ Object
Returns the value of attribute matches.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#patch_version ⇒ Object
readonly
Returns the value of attribute patch_version.
-
#player_id ⇒ Object
readonly
Returns the value of attribute player_id.
-
#shard_id ⇒ Object
readonly
Returns the value of attribute shard_id.
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
-
#title_id ⇒ Object
readonly
Returns the value of attribute title_id.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
Attributes inherited from RubgEndpoint
#data, #errors, #ratelimit, #ratelimit_remaining, #raw_response, #response_ts
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ Player
constructor
A new instance of Player.
Constructor Details
#initialize(args) ⇒ Player
Returns a new instance of Player.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rubg/player.rb', line 8 def initialize( args ) args = self.class.defaults.merge(args) super({ :response => args[:response] }) if args[:response]["data"] @player_id = args[:player_data]["id"] @name = args[:player_data]["attributes"]["name"] @created = args[:player_data]["attributes"]["createdAt"] @updated = args[:player_data]["attributes"]["updatedAt"] @patch_version = args[:player_data]["attributes"]["patchVersion"] @shard = args[:player_data]["attributes"]["shardId"] @stats = args[:player_data]["attributes"]["stats"] @title_id = args[:player_data]["attributes"]["titleId"] @assets = args[:player_data]["relationships"]["assets"]["data"] @match_ids = match_id_array(args[:player_data]["relationships"]["matches"]["data"]) @matches = nil @link = args[:player_data]["links"]["self"] end end |
Instance Attribute Details
#assets ⇒ Object (readonly)
Returns the value of attribute assets.
3 4 5 |
# File 'lib/rubg/player.rb', line 3 def assets @assets end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
3 4 5 |
# File 'lib/rubg/player.rb', line 3 def created @created end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
3 4 5 |
# File 'lib/rubg/player.rb', line 3 def link @link end |
#match_ids ⇒ Object (readonly)
Returns the value of attribute match_ids.
3 4 5 |
# File 'lib/rubg/player.rb', line 3 def match_ids @match_ids end |
#matches ⇒ Object
Returns the value of attribute matches.
6 7 8 |
# File 'lib/rubg/player.rb', line 6 def matches @matches end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/rubg/player.rb', line 3 def name @name end |
#patch_version ⇒ Object (readonly)
Returns the value of attribute patch_version.
3 4 5 |
# File 'lib/rubg/player.rb', line 3 def patch_version @patch_version end |
#player_id ⇒ Object (readonly)
Returns the value of attribute player_id.
3 4 5 |
# File 'lib/rubg/player.rb', line 3 def player_id @player_id end |
#shard_id ⇒ Object (readonly)
Returns the value of attribute shard_id.
3 4 5 |
# File 'lib/rubg/player.rb', line 3 def shard_id @shard_id end |
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
3 4 5 |
# File 'lib/rubg/player.rb', line 3 def stats @stats end |
#title_id ⇒ Object (readonly)
Returns the value of attribute title_id.
3 4 5 |
# File 'lib/rubg/player.rb', line 3 def title_id @title_id end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
3 4 5 |
# File 'lib/rubg/player.rb', line 3 def updated @updated end |
Class Method Details
.fetch(args) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rubg/player.rb', line 30 def self.fetch( args ) args = self.defaults.merge(args) endpoint = "player" player_id = args[:query_params][:player_id] args[:query_params].delete(:player_id) super({ :client => args[:client], :endpoint => endpoint, :lookup_id => player_id, :shard => args[:shard], :query_params => args[:query_params] }) player_data = @response["data"] RUBG::Player.new({ :client => args[:client], :response => @response, :player_data => player_data }) end |