Class: RUBG::Player

Inherits:
RubgEndpoint show all
Defined in:
lib/rubg/player.rb

Instance Attribute Summary collapse

Attributes inherited from RubgEndpoint

#data, #errors, #ratelimit, #ratelimit_remaining, #raw_response, #response_ts

Class Method Summary collapse

Instance Method Summary collapse

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

#assetsObject (readonly)

Returns the value of attribute assets.



3
4
5
# File 'lib/rubg/player.rb', line 3

def assets
  @assets
end

#createdObject (readonly)

Returns the value of attribute created.



3
4
5
# File 'lib/rubg/player.rb', line 3

def created
  @created
end

Returns the value of attribute link.



3
4
5
# File 'lib/rubg/player.rb', line 3

def link
  @link
end

#match_idsObject (readonly)

Returns the value of attribute match_ids.



3
4
5
# File 'lib/rubg/player.rb', line 3

def match_ids
  @match_ids
end

#matchesObject

Returns the value of attribute matches.



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

def matches
  @matches
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/rubg/player.rb', line 3

def name
  @name
end

#patch_versionObject (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_idObject (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_idObject (readonly)

Returns the value of attribute shard_id.



3
4
5
# File 'lib/rubg/player.rb', line 3

def shard_id
  @shard_id
end

#statsObject (readonly)

Returns the value of attribute stats.



3
4
5
# File 'lib/rubg/player.rb', line 3

def stats
  @stats
end

#title_idObject (readonly)

Returns the value of attribute title_id.



3
4
5
# File 'lib/rubg/player.rb', line 3

def title_id
  @title_id
end

#updatedObject (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