Class: Sportradar::Nhl::Models::PlayPlayerStat
- Inherits:
-
Object
- Object
- Sportradar::Nhl::Models::PlayPlayerStat
- Defined in:
- lib/sportradar/nhl/models/play_player_stat.rb
Direct Known Subclasses
Instance Method Summary collapse
- #clock ⇒ Object
- #description ⇒ Object
- #event ⇒ Object
- #event_id ⇒ Object
- #full_name ⇒ Object
- #goal? ⇒ Boolean
-
#initialize(event:, attributes:) ⇒ PlayPlayerStat
constructor
A new instance of PlayPlayerStat.
- #jersey ⇒ Object
- #penalty? ⇒ Boolean
- #period ⇒ Object
- #period_abbreviation ⇒ Object
- #period_number ⇒ Object
- #period_sequence ⇒ Object
- #period_type ⇒ Object
- #player ⇒ Object
- #player_id ⇒ Object
- #saved? ⇒ Boolean
- #shootout? ⇒ Boolean
- #stat ⇒ Object
- #strength ⇒ Object
- #team ⇒ Object
- #team_id ⇒ Object
- #team_market ⇒ Object
- #team_name ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
- #win? ⇒ Boolean
- #zone ⇒ Object
Constructor Details
#initialize(event:, attributes:) ⇒ PlayPlayerStat
Returns a new instance of PlayPlayerStat.
5 6 7 8 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 5 def initialize(event:, attributes:) @event = event @attributes = attributes end |
Instance Method Details
#clock ⇒ Object
53 54 55 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 53 def clock @event.clock end |
#description ⇒ Object
29 30 31 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 29 def description @event.description end |
#event ⇒ Object
21 22 23 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 21 def event @event end |
#event_id ⇒ Object
25 26 27 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 25 def event_id @event.id end |
#full_name ⇒ Object
69 70 71 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 69 def full_name player.dig('full_name') end |
#goal? ⇒ Boolean
104 105 106 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 104 def goal? @attributes.dig('goal') == true end |
#jersey ⇒ Object
65 66 67 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 65 def jersey player.dig('jersey') end |
#penalty? ⇒ Boolean
108 109 110 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 108 def penalty? type == 'penalty' end |
#period ⇒ Object
33 34 35 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 33 def period @event.period end |
#period_abbreviation ⇒ Object
37 38 39 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 37 def period_abbreviation period.abbreviation end |
#period_number ⇒ Object
41 42 43 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 41 def period_number period.number end |
#period_sequence ⇒ Object
45 46 47 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 45 def period_sequence period.sequence end |
#period_type ⇒ Object
49 50 51 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 49 def period_type period.type end |
#player ⇒ Object
57 58 59 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 57 def player @attributes.dig('player') || {} end |
#player_id ⇒ Object
61 62 63 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 61 def player_id player.dig('id') end |
#saved? ⇒ Boolean
112 113 114 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 112 def saved? @attributes.dig('saved') == true end |
#shootout? ⇒ Boolean
116 117 118 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 116 def shootout? @attributes.dig('shootout') == true end |
#stat ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 89 def stat { player_id: player_id, period_number: period_number, period_type: period_type, goal: goal?, penalty: penalty?, saved: saved?, shootout: shootout?, strength: strength, type: type, zone: zone, }.compact end |
#strength ⇒ Object
120 121 122 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 120 def strength @attributes.dig('strength') end |
#team ⇒ Object
73 74 75 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 73 def team @attributes.dig('team') || {} end |
#team_id ⇒ Object
77 78 79 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 77 def team_id team.dig('id') end |
#team_market ⇒ Object
81 82 83 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 81 def team_market team.dig('market') end |
#team_name ⇒ Object
85 86 87 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 85 def team_name team.dig('name') end |
#to_s ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 10 def to_s [ period_abbreviation, clock, description, team_name, full_name, stat, ].join(' ') end |
#type ⇒ Object
124 125 126 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 124 def type @attributes.dig('type') end |
#win? ⇒ Boolean
128 129 130 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 128 def win? @attributes.dig('win') == true end |
#zone ⇒ Object
132 133 134 |
# File 'lib/sportradar/nhl/models/play_player_stat.rb', line 132 def zone @attributes.dig('zone') end |