Class: RUBG::Match
- Inherits:
-
RubgEndpoint
- Object
- RubgEndpoint
- RUBG::Match
- Defined in:
- lib/rubg/match.rb
Instance Attribute Summary collapse
-
#assists ⇒ Object
readonly
Returns the value of attribute assists.
-
#boosts ⇒ Object
readonly
Returns the value of attribute boosts.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#damage_dealt ⇒ Object
readonly
Returns the value of attribute damage_dealt.
-
#damage_dealt_avg ⇒ Object
readonly
Returns the value of attribute damage_dealt_avg.
-
#dbnos ⇒ Object
readonly
Returns the value of attribute dbnos.
-
#death_types ⇒ Object
readonly
Returns the value of attribute death_types.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#headshot_kills ⇒ Object
readonly
Returns the value of attribute headshot_kills.
-
#heals ⇒ Object
readonly
Returns the value of attribute heals.
-
#kills ⇒ Object
readonly
Returns the value of attribute kills.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#map ⇒ Object
readonly
Returns the value of attribute map.
-
#match_id ⇒ Object
readonly
Returns the value of attribute match_id.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#participants ⇒ Object
Returns the value of attribute participants.
-
#patch_version ⇒ Object
readonly
Returns the value of attribute patch_version.
-
#player_count ⇒ Object
readonly
Returns the value of attribute player_count.
-
#revives ⇒ Object
readonly
Returns the value of attribute revives.
-
#ride_distance_avg ⇒ Object
readonly
Returns the value of attribute ride_distance_avg.
-
#road_kills ⇒ Object
readonly
Returns the value of attribute road_kills.
-
#roster_count ⇒ Object
readonly
Returns the value of attribute roster_count.
-
#rosters ⇒ Object
Returns the value of attribute rosters.
-
#rounds ⇒ Object
readonly
Returns the value of attribute rounds.
-
#shard ⇒ Object
readonly
Returns the value of attribute shard.
-
#spectators ⇒ Object
readonly
Returns the value of attribute spectators.
-
#stats ⇒ Object
readonly
Returns the value of attribute stats.
-
#survived ⇒ Object
readonly
Returns the value of attribute survived.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#team_kills ⇒ Object
readonly
Returns the value of attribute team_kills.
-
#telemetry_id ⇒ Object
readonly
Returns the value of attribute telemetry_id.
-
#telemetry_link ⇒ Object
readonly
Returns the value of attribute telemetry_link.
-
#time_survived_avg ⇒ Object
readonly
Returns the value of attribute time_survived_avg.
-
#title_id ⇒ Object
readonly
Returns the value of attribute title_id.
-
#vehicle_destroys ⇒ Object
readonly
Returns the value of attribute vehicle_destroys.
-
#walk_distance_avg ⇒ Object
readonly
Returns the value of attribute walk_distance_avg.
-
#weapons_acquired ⇒ Object
readonly
Returns the value of attribute weapons_acquired.
-
#winners ⇒ Object
(also: #winner)
readonly
Returns the value of attribute winners.
Attributes inherited from RubgEndpoint
#data, #errors, #ratelimit, #ratelimit_remaining, #raw_response, #response_ts
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ Match
constructor
A new instance of Match.
Constructor Details
#initialize(args) ⇒ Match
Returns a new instance of Match.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rubg/match.rb', line 13 def initialize( args ) args = self.class.defaults.merge(args) super({ :response => args[:response] }) if args[:response]["data"] @match_id = args[:match_data]["id"] @created = args[:match_data]["attributes"]["createdAt"] @duration = args[:match_data]["attributes"]["duration"] @mode = args[:match_data]["attributes"]["gameMode"] @map = convert_map_name(args[:match_data]["attributes"]["mapName"]) @patch_version = args[:match_data]["attributes"]["patchVersion"] @shard = args[:match_data]["attributes"]["shardId"] @stats = args[:match_data]["attributes"]["stats"] = args[:match_data]["attributes"]["tags"] @title_id = args[:match_data]["attributes"]["titleId"] @telemetry_id = args[:match_data]["relationships"]["assets"]["data"][0]["id"] @rounds = args[:match_data]["relationships"]["rounds"]["data"] @spectators = args[:match_data]["relationships"]["spectators"]["data"] @link = args[:match_data]["links"]["self"] @telemetry_link = args[:match_included].detect {|i| i["type"] == "asset" }["attributes"]["URL"] @rosters = [] @participants = [] generate_roster_objects(args[:match_included]) @player_count = @participants.count @roster_count = @rosters.count @winners = @rosters.detect {|r| r.won} #aggregates @names = @participants.collect(&:name).sort! @survived = @participants.select {|m| m.death_type == "alive"} @dbnos = @participants.sum {|m| m.dbnos} @assists = @participants.sum {|m| m.assists} @boosts = @participants.sum {|m| m.boosts} @damage_dealt = @participants.sum {|m| m.damage_dealt} @damage_dealt_avg = ((participants.sum {|m| m.damage_dealt}).to_f/self.player_count.to_f).to_i @headshot_kills = @participants.sum {|m| m.headshot_kills} @heals = @participants.sum {|m| m.heals} @kills = @participants.sum {|m| m.kills} @ride_distance_avg = ((participants.sum {|m| m.ride_distance}).to_f/self.player_count.to_f).to_i @revives = @participants.sum {|m| m.revives} @road_kills = @participants.sum {|m| m.road_kills} @team_kills = @participants.sum {|m| m.team_kills} @time_survived_avg = ((participants.sum {|m| m.time_survived}).to_f/self.player_count.to_f).to_i @vehicle_destroys = @participants.sum {|m| m.vehicle_destroys} @walk_distance_avg = ((participants.sum {|m| m.walk_distance}).to_f/self.player_count.to_f).to_i @weapons_acquired = @participants.sum {|m| m.weapons_acquired} end end |
Instance Attribute Details
#assists ⇒ Object (readonly)
Returns the value of attribute assists.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def assists @assists end |
#boosts ⇒ Object (readonly)
Returns the value of attribute boosts.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def boosts @boosts end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def created @created end |
#damage_dealt ⇒ Object (readonly)
Returns the value of attribute damage_dealt.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def damage_dealt @damage_dealt end |
#damage_dealt_avg ⇒ Object (readonly)
Returns the value of attribute damage_dealt_avg.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def damage_dealt_avg @damage_dealt_avg end |
#dbnos ⇒ Object (readonly)
Returns the value of attribute dbnos.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def dbnos @dbnos end |
#death_types ⇒ Object (readonly)
Returns the value of attribute death_types.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def death_types @death_types end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def duration @duration end |
#headshot_kills ⇒ Object (readonly)
Returns the value of attribute headshot_kills.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def headshot_kills @headshot_kills end |
#heals ⇒ Object (readonly)
Returns the value of attribute heals.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def heals @heals end |
#kills ⇒ Object (readonly)
Returns the value of attribute kills.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def kills @kills end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def link @link end |
#map ⇒ Object (readonly)
Returns the value of attribute map.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def map @map end |
#match_id ⇒ Object (readonly)
Returns the value of attribute match_id.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def match_id @match_id end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def mode @mode end |
#names ⇒ Object (readonly)
Returns the value of attribute names.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def names @names end |
#participants ⇒ Object
Returns the value of attribute participants.
10 11 12 |
# File 'lib/rubg/match.rb', line 10 def participants @participants end |
#patch_version ⇒ Object (readonly)
Returns the value of attribute patch_version.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def patch_version @patch_version end |
#player_count ⇒ Object (readonly)
Returns the value of attribute player_count.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def player_count @player_count end |
#revives ⇒ Object (readonly)
Returns the value of attribute revives.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def revives @revives end |
#ride_distance_avg ⇒ Object (readonly)
Returns the value of attribute ride_distance_avg.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def ride_distance_avg @ride_distance_avg end |
#road_kills ⇒ Object (readonly)
Returns the value of attribute road_kills.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def road_kills @road_kills end |
#roster_count ⇒ Object (readonly)
Returns the value of attribute roster_count.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def roster_count @roster_count end |
#rosters ⇒ Object
Returns the value of attribute rosters.
10 11 12 |
# File 'lib/rubg/match.rb', line 10 def rosters @rosters end |
#rounds ⇒ Object (readonly)
Returns the value of attribute rounds.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def rounds @rounds end |
#shard ⇒ Object (readonly)
Returns the value of attribute shard.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def shard @shard end |
#spectators ⇒ Object (readonly)
Returns the value of attribute spectators.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def spectators @spectators end |
#stats ⇒ Object (readonly)
Returns the value of attribute stats.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def stats @stats end |
#survived ⇒ Object (readonly)
Returns the value of attribute survived.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def survived @survived end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def end |
#team_kills ⇒ Object (readonly)
Returns the value of attribute team_kills.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def team_kills @team_kills end |
#telemetry_id ⇒ Object (readonly)
Returns the value of attribute telemetry_id.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def telemetry_id @telemetry_id end |
#telemetry_link ⇒ Object (readonly)
Returns the value of attribute telemetry_link.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def telemetry_link @telemetry_link end |
#time_survived_avg ⇒ Object (readonly)
Returns the value of attribute time_survived_avg.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def time_survived_avg @time_survived_avg end |
#title_id ⇒ Object (readonly)
Returns the value of attribute title_id.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def title_id @title_id end |
#vehicle_destroys ⇒ Object (readonly)
Returns the value of attribute vehicle_destroys.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def vehicle_destroys @vehicle_destroys end |
#walk_distance_avg ⇒ Object (readonly)
Returns the value of attribute walk_distance_avg.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def walk_distance_avg @walk_distance_avg end |
#weapons_acquired ⇒ Object (readonly)
Returns the value of attribute weapons_acquired.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def weapons_acquired @weapons_acquired end |
#winners ⇒ Object (readonly) Also known as: winner
Returns the value of attribute winners.
3 4 5 |
# File 'lib/rubg/match.rb', line 3 def winners @winners end |
Class Method Details
.fetch(args) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/rubg/match.rb', line 68 def self.fetch( args ) args = self.defaults.merge(args) endpoint = "match" match_id = args[:query_params][:match_id] args[:query_params].delete(:match_id) super({ :client => args[:client], :endpoint => endpoint, :lookup_id => match_id, :shard => args[:shard], :query_params => args[:query_params] }) match_data = @response["data"] match_included = @response["included"] RUBG::Match.new({ :client => args[:client], :response => @response, :match_data => match_data, :match_included => match_included }) end |