Class: Match
- Inherits:
-
Object
- Object
- Match
- Defined in:
- lib/api/utils/match.rb
Overview
This class is used to get the data from a match
Instance Attribute Summary collapse
-
#all_players ⇒ Object
readonly
Returns the value of attribute all_players.
-
#blue_rounds_lost ⇒ Object
readonly
Returns the value of attribute blue_rounds_lost.
-
#blue_rounds_won ⇒ Object
readonly
Returns the value of attribute blue_rounds_won.
-
#blue_team ⇒ Object
readonly
Returns the value of attribute blue_team.
-
#cluster ⇒ Object
readonly
Returns the value of attribute cluster.
-
#game_length ⇒ Object
readonly
Returns the value of attribute game_length.
-
#game_start ⇒ Object
readonly
Returns the value of attribute game_start.
-
#game_start_patched ⇒ Object
readonly
Returns the value of attribute game_start_patched.
-
#game_version ⇒ Object
readonly
Returns the value of attribute game_version.
-
#map ⇒ Object
readonly
Returns the value of attribute map.
-
#matchid ⇒ Object
readonly
Returns the value of attribute matchid.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#red_rounds_lost ⇒ Object
readonly
Returns the value of attribute red_rounds_lost.
-
#red_rounds_won ⇒ Object
readonly
Returns the value of attribute red_rounds_won.
-
#red_team ⇒ Object
readonly
Returns the value of attribute red_team.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#rounds_played ⇒ Object
readonly
Returns the value of attribute rounds_played.
-
#season_id ⇒ Object
readonly
Returns the value of attribute season_id.
-
#winning_team ⇒ Object
readonly
Returns the value of attribute winning_team.
Instance Method Summary collapse
- #accuracy(name, tag) ⇒ Object
-
#initialize(data) ⇒ Match
constructor
A new instance of Match.
- #mvp ⇒ Object
- #mvp_blue ⇒ Object
- #mvp_red ⇒ Object
- #player(name, tag) ⇒ Object
Constructor Details
#initialize(data) ⇒ Match
Returns a new instance of Match.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/api/utils/match.rb', line 12 def initialize(data) @meta_data = data['data']['metadata'] @player_data = data['data']['players'] @team_data = data['data']['teams'] fetch_game_info fetch_game_type fetch_game_statistics fetch_players end |
Instance Attribute Details
#all_players ⇒ Object (readonly)
Returns the value of attribute all_players.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def all_players @all_players end |
#blue_rounds_lost ⇒ Object (readonly)
Returns the value of attribute blue_rounds_lost.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def blue_rounds_lost @blue_rounds_lost end |
#blue_rounds_won ⇒ Object (readonly)
Returns the value of attribute blue_rounds_won.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def blue_rounds_won @blue_rounds_won end |
#blue_team ⇒ Object (readonly)
Returns the value of attribute blue_team.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def blue_team @blue_team end |
#cluster ⇒ Object (readonly)
Returns the value of attribute cluster.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def cluster @cluster end |
#game_length ⇒ Object (readonly)
Returns the value of attribute game_length.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def game_length @game_length end |
#game_start ⇒ Object (readonly)
Returns the value of attribute game_start.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def game_start @game_start end |
#game_start_patched ⇒ Object (readonly)
Returns the value of attribute game_start_patched.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def game_start_patched @game_start_patched end |
#game_version ⇒ Object (readonly)
Returns the value of attribute game_version.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def game_version @game_version end |
#map ⇒ Object (readonly)
Returns the value of attribute map.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def map @map end |
#matchid ⇒ Object (readonly)
Returns the value of attribute matchid.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def matchid @matchid end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def mode @mode end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def platform @platform end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def queue @queue end |
#red_rounds_lost ⇒ Object (readonly)
Returns the value of attribute red_rounds_lost.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def red_rounds_lost @red_rounds_lost end |
#red_rounds_won ⇒ Object (readonly)
Returns the value of attribute red_rounds_won.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def red_rounds_won @red_rounds_won end |
#red_team ⇒ Object (readonly)
Returns the value of attribute red_team.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def red_team @red_team end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def region @region end |
#rounds_played ⇒ Object (readonly)
Returns the value of attribute rounds_played.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def rounds_played @rounds_played end |
#season_id ⇒ Object (readonly)
Returns the value of attribute season_id.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def season_id @season_id end |
#winning_team ⇒ Object (readonly)
Returns the value of attribute winning_team.
7 8 9 |
# File 'lib/api/utils/match.rb', line 7 def winning_team @winning_team end |
Instance Method Details
#accuracy(name, tag) ⇒ Object
36 37 38 39 |
# File 'lib/api/utils/match.rb', line 36 def accuracy(name, tag) result = @all_players.select { |player| player.name.gsub(' ', '') == name.gsub(' ', '') && player.tag == tag } [result[0].headshots, result[0].bodyshots, result[0].legshots] end |
#mvp ⇒ Object
24 25 26 |
# File 'lib/api/utils/match.rb', line 24 def mvp @all_players.max_by(&:score) end |
#mvp_blue ⇒ Object
32 33 34 |
# File 'lib/api/utils/match.rb', line 32 def mvp_blue @blue_team.max_by(&:score) end |
#mvp_red ⇒ Object
28 29 30 |
# File 'lib/api/utils/match.rb', line 28 def mvp_red @red_team.max_by(&:score) end |
#player(name, tag) ⇒ Object
41 42 43 |
# File 'lib/api/utils/match.rb', line 41 def player(name, tag) @all_players.select { |player| player.name.gsub(' ', '') == name.gsub(' ', '') && player.tag == tag } end |