Class: RUBG::PlayerCollection

Inherits:
RubgEndpoint show all
Defined in:
lib/rubg/player_collection.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) ⇒ PlayerCollection

Returns a new instance of PlayerCollection.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rubg/player_collection.rb', line 5

def initialize( args )
  args     = self.class.defaults.merge(args)

  super
  
  @players = []
  if args[:response]["data"]
    args[:response]["data"].each do |player_data|
      player = RUBG::Player.new({
        :client       => args[:client],
        :response     => args[:response],
        :player_data  => player_data
        })
      

      @players << player
    end
  end
end

Instance Attribute Details

#playersObject (readonly)

Returns the value of attribute players.



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

def players
  @players
end

Class Method Details

.fetch(args) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rubg/player_collection.rb', line 26

def self.fetch( args )
  args     = self.defaults.merge(args)

  endpoint = "players"

  args[:query_params]["filter[playerNames]"] = args[:query_params].delete(:player_names)
  args[:query_params]["filter[playerIds]"]   = args[:query_params].delete(:player_ids)
  super({
    :client         => args[:client],
    :endpoint       => endpoint,
    :shard          => args[:shard],
    :query_params  => args[:query_params]
    })

  RUBG::PlayerCollection.new({
    :client   => args[:client],
    :response => @response
    })
end