Class: AhlScraper::Games::Penalty
- Inherits:
-
Resource
- Object
- Resource
- AhlScraper::Games::Penalty
show all
- Defined in:
- lib/ahl_scraper/resources/games/penalty.rb
Instance Method Summary
collapse
Methods inherited from Resource
#[], #each, #initialize, #inspect, #keys, #to_json, #values
Instance Method Details
#bench? ⇒ Boolean
80
81
82
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 80
def bench?
@raw_data[:isBench]
end
|
#description ⇒ Object
68
69
70
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 68
def description
@description ||= @raw_data[:description]
end
|
#duration ⇒ Object
60
61
62
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 60
def duration
@duration ||= "#{minutes}:00"
end
|
#duration_in_seconds ⇒ Object
64
65
66
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 64
def duration_in_seconds
@duration_in_seconds ||= minutes * 60
end
|
#game_time_elapsed ⇒ Object
26
27
28
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 26
def game_time_elapsed
@game_time_elapsed ||= period_time.to_elapsed
end
|
#id ⇒ Object
6
7
8
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 6
def id
@id ||= @raw_data[:game_penalty_id]&.to_i
end
|
#invalid? ⇒ Boolean
84
85
86
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 84
def invalid?
[240_773].include? id
end
|
#minutes ⇒ Object
56
57
58
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 56
def minutes
@minutes ||= @raw_data[:minutes]
end
|
#number ⇒ Object
10
11
12
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 10
def number
@number ||= @opts[:number]
end
|
#penalized_team ⇒ Object
52
53
54
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 52
def penalized_team
@penalized_team ||= @raw_data[:againstTeam]
end
|
#penalty_type ⇒ Object
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 88
def penalty_type
@penalty_type ||=
case @raw_data[:description]
when /penalty shot/i
:penalty_shot
when /double minor/i
:double_minor
when /major/i
:major
when /fighting/i
:fight
when /game misconduct/i
:game_misconduct
when /misconduct/i
:misconduct
else
:minor
end
end
|
#period ⇒ Object
14
15
16
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 14
def period
@period ||= @raw_data.dig(:period, :id)&.to_i
end
|
#period_time_in_seconds ⇒ Object
22
23
24
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 22
def period_time_in_seconds
@period_time_in_seconds ||= period_time.to_sec
end
|
#power_play? ⇒ Boolean
76
77
78
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 76
def power_play?
@raw_data[:isPowerPlay]
end
|
#rule_number ⇒ Object
72
73
74
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 72
def rule_number
@rule_number ||= @raw_data[:rule_number]
end
|
#served_by ⇒ Object
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 41
def served_by
@served_by ||= {
id: @raw_data.dig(:servedBy, :id)&.positive? ? @raw_data.dig(:servedBy, :id) : nil,
first_name: @raw_data.dig(:servedBy, :firstName),
last_name: @raw_data.dig(:servedBy, :lastName),
jersey_number: @raw_data.dig(:servedBy, :jerseyNumber),
position: @raw_data.dig(:servedBy, :position),
birthdate: @raw_data.dig(:servedBy, :birthdate),
}
end
|
#taken_by ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 30
def taken_by
@taken_by ||= {
id: @raw_data.dig(:takenBy, :id)&.positive? ? @raw_data.dig(:takenBy, :id) : nil,
first_name: @raw_data.dig(:takenBy, :firstName),
last_name: @raw_data.dig(:takenBy, :lastName),
jersey_number: @raw_data.dig(:takenBy, :jerseyNumber),
position: @raw_data.dig(:takenBy, :position),
birthdate: @raw_data.dig(:takenBy, :birthdate),
}
end
|
#time ⇒ Object
18
19
20
|
# File 'lib/ahl_scraper/resources/games/penalty.rb', line 18
def time
@time ||= @raw_data[:time]
end
|