Class: Sportradar::Nhl::Models::Penalty
- Inherits:
-
Event
- Object
- Event
- Sportradar::Nhl::Models::Penalty
show all
- Defined in:
- lib/sportradar/nhl/models/penalty.rb
Constant Summary
Constants inherited
from Event
Event::EVENT_TYPES, Event::PENALTY_TYPES, Event::PLAY_TYPES, Event::SCORING_PLAY_TYPES, Event::STOPPAGE_TYPES
Instance Method Summary
collapse
Methods inherited from Event
#clock, #clock_secs, #coordinate_x, #coordinate_y, #coordinates, #coordinates?, #description, #event_type, #game_id, #has_team?, #id, #initialize, #official, #penalty?, #period, #period_abbreviation, #period_id, #period_number, #period_sequence, #period_type, #play?, #play_player_stats, #scoring_play?, #scoring_players, #statistics, #stoppage?, #strength, #team, #team_goal_side, #team_id, #time_code, #updated_at, #wall_clock, #zone
Instance Method Details
#duration ⇒ Object
9
10
11
|
# File 'lib/sportradar/nhl/models/penalty.rb', line 9
def duration
@attributes.dig('duration')
end
|
#minutes ⇒ Object
13
14
15
|
# File 'lib/sportradar/nhl/models/penalty.rb', line 13
def minutes
duration.to_i
end
|
#name ⇒ Object
17
18
19
|
# File 'lib/sportradar/nhl/models/penalty.rb', line 17
def name
ActiveSupport::Inflector.parameterize(penalty_type)
end
|
#penalty_type ⇒ Object
Also known as:
label
21
22
23
|
# File 'lib/sportradar/nhl/models/penalty.rb', line 21
def penalty_type
@attributes.dig('penalty_type')
end
|
#player_id ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'lib/sportradar/nhl/models/penalty.rb', line 26
def player_id
play_player_stats.each do |stat|
if stat.penalty? && !stat.player_id.nil?
return stat.player_id
end
end
nil
end
|
#seconds ⇒ Object
36
37
38
|
# File 'lib/sportradar/nhl/models/penalty.rb', line 36
def seconds
minutes * 60
end
|
#team_penalty ⇒ Object
40
41
42
|
# File 'lib/sportradar/nhl/models/penalty.rb', line 40
def team_penalty
false
end
|
#to_h ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/sportradar/nhl/models/penalty.rb', line 44
def to_h
{
id: id,
game_id: game_id,
player_id: player_id,
team_id: team_id,
minutes: minutes,
name: name,
period_number: period_number,
period_seconds: period_seconds,
sports_ml_key: id,
team_penalty: team_penalty,
time_code: time_code,
seconds: seconds,
}
end
|
#to_s ⇒ Object
5
6
7
|
# File 'lib/sportradar/nhl/models/penalty.rb', line 5
def to_s
"#{super} - #{minutes} mins - #{label}"
end
|