Class: AhlScraper::Games::Goal
Instance Method Summary
collapse
Methods inherited from Resource
#[], #each, #initialize, #inspect, #keys, #to_json, #values
Instance Method Details
#assist_numbers ⇒ Object
56
57
58
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 56
def assist_numbers
@assist_numbers ||= @raw_data[:assistNumbers]
end
|
#assists ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 44
def assists
@assists ||= @raw_data[:assists].map do |assist|
{
id: assist[:id],
first_name: assist[:firstName],
last_name: assist[:lastName],
number: assist[:jerseyNumber],
position: assist[:position],
}
end
end
|
#description ⇒ Object
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 117
def description
@description ||=
if assists.nil? || assists.empty?
goalscorer_name
elsif assists.length == 1
"#{goalscorer_name} (#{a1_name})"
else
"#{goalscorer_name} (#{a1_name}, #{a2_name})"
end
end
|
#empty_net? ⇒ Boolean
72
73
74
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 72
def empty_net?
@empty_net ||= @raw_data[:properties][:isEmptyNet] == "1"
end
|
76
77
78
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 76
def
@extra_skater ||=
end
|
#game_time_elapsed ⇒ Object
26
27
28
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 26
def game_time_elapsed
@game_time_elapsed ||= period_time.to_elapsed
end
|
#game_winner? ⇒ Boolean
88
89
90
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 88
def game_winner?
@game_winner ||= @raw_data[:properties][:isGameWinningGoal] == "1"
end
|
#id ⇒ Object
6
7
8
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 6
def id
@id ||= @raw_data[:game_goal_id]
end
|
#insurance_goal? ⇒ Boolean
84
85
86
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 84
def insurance_goal?
@insurance_goal ||= @raw_data[:properties][:isInsuranceGoal] == "1"
end
|
#minus_players ⇒ Object
96
97
98
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 96
def minus_players
@minus_players ||= @raw_data[:minus_players].map { |player| OnIceSkater.new(player, { scoring_team: false, goal_id: id }) }
end
|
#number ⇒ Object
10
11
12
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 10
def number
@number ||= @opts[:number]
end
|
#penalty_shot? ⇒ Boolean
80
81
82
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 80
def penalty_shot?
@penalty_shot ||= @raw_data[:properties][:isPenaltyShot] == "1"
end
|
#period ⇒ Object
14
15
16
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 14
def period
@period ||= @raw_data[:period][:id].to_i
end
|
#period_time_in_seconds ⇒ Object
22
23
24
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 22
def period_time_in_seconds
@period_time_in_seconds ||= period_time.to_sec
end
|
#plus_players ⇒ Object
92
93
94
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 92
def plus_players
@plus_players ||= @raw_data[:plus_players].map { |player| OnIceSkater.new(player, { scoring_team: true, goal_id: id }) }
end
|
#power_play? ⇒ Boolean
64
65
66
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 64
def power_play?
@power_play ||= @raw_data[:properties][:isPowerPlay] == "1"
end
|
#scored_by ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 34
def scored_by
@scored_by ||= {
id: @raw_data[:scoredBy][:id],
first_name: @raw_data[:scoredBy][:firstName],
last_name: @raw_data[:scoredBy][:lastName],
number: @raw_data[:scoredBy][:jerseyNumber],
position: @raw_data[:scoredBy][:position],
}
end
|
#scorer_goal_number ⇒ Object
30
31
32
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 30
def scorer_goal_number
@scorer_goal_number ||= @raw_data[:scorerGoalNumber]
end
|
#scoring_team ⇒ Object
60
61
62
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 60
def scoring_team
@scoring_team ||= @raw_data[:team]
end
|
#short_handed? ⇒ Boolean
68
69
70
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 68
def short_handed?
@short_handed ||= @raw_data[:properties][:isShortHanded] == "1"
end
|
#situation ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 100
def situation
@situation ||=
if @raw_data[:properties][:isPowerPlay] == "1"
"PP"
elsif @raw_data[:properties][:isShortHanded] == "1"
"SH"
elsif @raw_data[:properties][:isEmptyNet] == "1"
"EN"
elsif == true
"EX"
elsif @raw_data[:properties][:isPenaltyShot] == "1"
"PS"
else
"EV"
end
end
|
#special_teams? ⇒ Boolean
128
129
130
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 128
def special_teams?
@special_teams ||= short_handed? || power_play?
end
|
#time ⇒ Object
18
19
20
|
# File 'lib/ahl_scraper/resources/games/goal.rb', line 18
def time
@time ||= @raw_data[:time]
end
|