Class: RUBG::Roster
- Inherits:
-
Object
- Object
- RUBG::Roster
- Defined in:
- lib/rubg/roster.rb
Instance Attribute Summary collapse
-
#assists ⇒ Object
readonly
Returns the value of attribute assists.
-
#boosts ⇒ Object
readonly
Returns the value of attribute boosts.
-
#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
(also: #knocks)
readonly
Returns the value of attribute dbnos.
-
#death_types ⇒ Object
readonly
Returns the value of attribute death_types.
-
#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.
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#participant_ids ⇒ Object
readonly
Returns the value of attribute participant_ids.
-
#participants ⇒ Object
Returns the value of attribute participants.
-
#rank ⇒ Object
readonly
Returns the value of attribute rank.
-
#revives ⇒ Object
readonly
Returns the value of attribute revives.
-
#ride_distance ⇒ Object
readonly
Returns the value of attribute ride_distance.
-
#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_id ⇒ Object
readonly
Returns the value of attribute roster_id.
-
#shard ⇒ Object
readonly
Returns the value of attribute shard.
-
#size ⇒ Object
(also: #player_count)
readonly
Returns the value of attribute size.
-
#survived ⇒ Object
readonly
Returns the value of attribute survived.
-
#team ⇒ Object
readonly
Returns the value of attribute team.
-
#team_id ⇒ Object
readonly
Returns the value of attribute team_id.
-
#team_kills ⇒ Object
readonly
Returns the value of attribute team_kills.
-
#time_survived ⇒ Object
readonly
Returns the value of attribute time_survived.
-
#time_survived_avg ⇒ Object
readonly
Returns the value of attribute time_survived_avg.
-
#vehicle_destroys ⇒ Object
readonly
Returns the value of attribute vehicle_destroys.
-
#walk_distance ⇒ Object
readonly
Returns the value of attribute walk_distance.
-
#walk_distance_avg ⇒ Object
readonly
Returns the value of attribute walk_distance_avg.
-
#weapons_acquired ⇒ Object
readonly
Returns the value of attribute weapons_acquired.
-
#won ⇒ Object
readonly
Returns the value of attribute won.
Instance Method Summary collapse
-
#initialize(args) ⇒ Roster
constructor
A new instance of Roster.
- #won? ⇒ Boolean
Constructor Details
#initialize(args) ⇒ Roster
Returns a new instance of Roster.
12 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 |
# File 'lib/rubg/roster.rb', line 12 def initialize( args ) if args[:roster_hash] @roster_id = args[:roster_hash]["id"] @shard = args[:roster_hash]["attributes"]["shardId"] @team_id = args[:roster_hash]["attributes"]["stats"]["teamId"] @team = args[:roster_hash]["relationships"]["team"]["data"] @rank = args[:roster_hash]["attributes"]["stats"]["rank"] @won = args[:roster_hash]["attributes"]["won"] == "true" ? true : false @participants = [] generate_participant_objects(args[:participant_array]) @size = @participants.count #aggregate roster stats @names = @participants.collect(&:name) @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.size.to_f).to_i @death_types = @participants.collect(&:death_type) @headshot_kills = @participants.sum {|m| m.headshot_kills} @heals = @participants.sum {|m| m.heals} @kills = @participants.sum {|m| m.kills} @ride_distance = @participants.sum {|m| m.ride_distance} @ride_distance_avg = ((participants.sum {|m| m.ride_distance}).to_f/self.size.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 = @participants.sum {|m| m.time_survived} @time_survived_avg = ((participants.sum {|m| m.time_survived}).to_f/self.size.to_f).to_i @vehicle_destroys = @participants.sum {|m| m.vehicle_destroys} @walk_distance = @participants.sum {|m| m.walk_distance} @walk_distance_avg = ((participants.sum {|m| m.walk_distance}).to_f/self.size.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/roster.rb', line 3 def assists @assists end |
#boosts ⇒ Object (readonly)
Returns the value of attribute boosts.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def boosts @boosts end |
#damage_dealt ⇒ Object (readonly)
Returns the value of attribute damage_dealt.
3 4 5 |
# File 'lib/rubg/roster.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/roster.rb', line 3 def damage_dealt_avg @damage_dealt_avg end |
#dbnos ⇒ Object (readonly) Also known as: knocks
Returns the value of attribute dbnos.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def dbnos @dbnos end |
#death_types ⇒ Object (readonly)
Returns the value of attribute death_types.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def death_types @death_types end |
#headshot_kills ⇒ Object (readonly)
Returns the value of attribute headshot_kills.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def headshot_kills @headshot_kills end |
#heals ⇒ Object (readonly)
Returns the value of attribute heals.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def heals @heals end |
#kills ⇒ Object (readonly)
Returns the value of attribute kills.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def kills @kills end |
#names ⇒ Object (readonly)
Returns the value of attribute names.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def names @names end |
#participant_ids ⇒ Object (readonly)
Returns the value of attribute participant_ids.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def participant_ids @participant_ids end |
#participants ⇒ Object
Returns the value of attribute participants.
8 9 10 |
# File 'lib/rubg/roster.rb', line 8 def participants @participants end |
#rank ⇒ Object (readonly)
Returns the value of attribute rank.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def rank @rank end |
#revives ⇒ Object (readonly)
Returns the value of attribute revives.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def revives @revives end |
#ride_distance ⇒ Object (readonly)
Returns the value of attribute ride_distance.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def ride_distance @ride_distance end |
#ride_distance_avg ⇒ Object (readonly)
Returns the value of attribute ride_distance_avg.
3 4 5 |
# File 'lib/rubg/roster.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/roster.rb', line 3 def road_kills @road_kills end |
#roster_id ⇒ Object (readonly)
Returns the value of attribute roster_id.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def roster_id @roster_id end |
#shard ⇒ Object (readonly)
Returns the value of attribute shard.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def shard @shard end |
#size ⇒ Object (readonly) Also known as: player_count
Returns the value of attribute size.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def size @size end |
#survived ⇒ Object (readonly)
Returns the value of attribute survived.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def survived @survived end |
#team ⇒ Object (readonly)
Returns the value of attribute team.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def team @team end |
#team_id ⇒ Object (readonly)
Returns the value of attribute team_id.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def team_id @team_id end |
#team_kills ⇒ Object (readonly)
Returns the value of attribute team_kills.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def team_kills @team_kills end |
#time_survived ⇒ Object (readonly)
Returns the value of attribute time_survived.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def time_survived @time_survived end |
#time_survived_avg ⇒ Object (readonly)
Returns the value of attribute time_survived_avg.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def time_survived_avg @time_survived_avg end |
#vehicle_destroys ⇒ Object (readonly)
Returns the value of attribute vehicle_destroys.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def vehicle_destroys @vehicle_destroys end |
#walk_distance ⇒ Object (readonly)
Returns the value of attribute walk_distance.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def walk_distance @walk_distance end |
#walk_distance_avg ⇒ Object (readonly)
Returns the value of attribute walk_distance_avg.
3 4 5 |
# File 'lib/rubg/roster.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/roster.rb', line 3 def weapons_acquired @weapons_acquired end |
#won ⇒ Object (readonly)
Returns the value of attribute won.
3 4 5 |
# File 'lib/rubg/roster.rb', line 3 def won @won end |
Instance Method Details
#won? ⇒ Boolean
52 53 54 |
# File 'lib/rubg/roster.rb', line 52 def won? @won end |