ahl_scraper 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/CHANGELOG.md +49 -0
  4. data/Gemfile +8 -8
  5. data/Gemfile.lock +46 -41
  6. data/ahl_scraper.gemspec +1 -1
  7. data/lib/ahl_scraper/fetchers/game_data_fetcher.rb +1 -1
  8. data/lib/ahl_scraper/fetchers/player_data_fetcher.rb +1 -1
  9. data/lib/ahl_scraper/fetchers/player_games/data_fetcher.rb +1 -1
  10. data/lib/ahl_scraper/fetchers/season_type_fetcher.rb +1 -2
  11. data/lib/ahl_scraper/fixed_games/1001050.json +18 -18
  12. data/lib/ahl_scraper/fixed_games/1003351.json +2728 -0
  13. data/lib/ahl_scraper/fixed_games/1018774.json +4 -4
  14. data/lib/ahl_scraper/fixed_games/1020527.json +8 -8
  15. data/lib/ahl_scraper/resources/game.rb +4 -3
  16. data/lib/ahl_scraper/resources/game_list_item.rb +13 -13
  17. data/lib/ahl_scraper/resources/games/info.rb +1 -1
  18. data/lib/ahl_scraper/resources/games/penalty.rb +2 -2
  19. data/lib/ahl_scraper/resources/games/team.rb +2 -2
  20. data/lib/ahl_scraper/resources/goalie_game_list_item.rb +2 -1
  21. data/lib/ahl_scraper/resources/player.rb +2 -2
  22. data/lib/ahl_scraper/resources/playoff_bracket.rb +5 -5
  23. data/lib/ahl_scraper/resources/playoff_brackets/round.rb +1 -1
  24. data/lib/ahl_scraper/resources/playoff_brackets/series.rb +60 -20
  25. data/lib/ahl_scraper/resources/roster_player.rb +1 -1
  26. data/lib/ahl_scraper/resources/season.rb +13 -8
  27. data/lib/ahl_scraper/resources/season_list_item.rb +2 -2
  28. data/lib/ahl_scraper/resources/seasons/team.rb +4 -3
  29. data/lib/ahl_scraper/resources/skater_game_list_item.rb +2 -2
  30. data/lib/ahl_scraper/resources/team_game_list_item.rb +2 -3
  31. data/lib/ahl_scraper/resources/team_list_item.rb +1 -1
  32. data/lib/ahl_scraper/services/games/create_skaters_service.rb +1 -1
  33. data/lib/ahl_scraper/services/games/on_ice_statlines_service.rb +1 -1
  34. data/lib/ahl_scraper/services/games/scoring_statlines_service.rb +29 -25
  35. data/lib/ahl_scraper/services/games/team_on_ice_goals_service.rb +1 -1
  36. data/lib/ahl_scraper/team_games.rb +3 -1
  37. data/lib/ahl_scraper/version.rb +1 -1
  38. metadata +5 -4
@@ -1438,7 +1438,7 @@
1438
1438
  ],
1439
1439
  "penalties": [
1440
1440
  {
1441
- "game_penalty_id": 219063,
1441
+ "game_penalty_id": 219032,
1442
1442
  "period": { "id": "1", "shortName": "", "longName": "1st" },
1443
1443
  "time": "11:54",
1444
1444
  "againstTeam": {
@@ -1473,7 +1473,7 @@
1473
1473
  "isBench": false
1474
1474
  },
1475
1475
  {
1476
- "game_penalty_id": 219076,
1476
+ "game_penalty_id": 219034,
1477
1477
  "period": { "id": "1", "shortName": "", "longName": "1st" },
1478
1478
  "time": "16:43",
1479
1479
  "againstTeam": {
@@ -2057,7 +2057,7 @@
2057
2057
  ],
2058
2058
  "penalties": [
2059
2059
  {
2060
- "game_penalty_id": 774,
2060
+ "game_penalty_id": 219045,
2061
2061
  "period": { "id": "2", "shortName": "", "longName": "2nd" },
2062
2062
  "time": "17:58",
2063
2063
  "againstTeam": {
@@ -2381,7 +2381,7 @@
2381
2381
  ],
2382
2382
  "penalties": [
2383
2383
  {
2384
- "game_penalty_id": 1234,
2384
+ "game_penalty_id": 219082,
2385
2385
  "period": { "id": "3", "shortName": "", "longName": "3rd" },
2386
2386
  "time": "4:19",
2387
2387
  "againstTeam": {
@@ -1768,7 +1768,7 @@
1768
1768
  ],
1769
1769
  "penalties": [
1770
1770
  {
1771
- "game_penalty_id": null,
1771
+ "game_penalty_id": 237213,
1772
1772
  "period": { "id": "2", "shortName": "", "longName": "2nd" },
1773
1773
  "time": "2:08",
1774
1774
  "againstTeam": {
@@ -1803,7 +1803,7 @@
1803
1803
  "isBench": false
1804
1804
  },
1805
1805
  {
1806
- "game_penalty_id": null,
1806
+ "game_penalty_id": 237215,
1807
1807
  "period": { "id": "2", "shortName": "", "longName": "2nd" },
1808
1808
  "time": "4:52",
1809
1809
  "againstTeam": {
@@ -1831,7 +1831,7 @@
1831
1831
  "isBench": true
1832
1832
  },
1833
1833
  {
1834
- "game_penalty_id": null,
1834
+ "game_penalty_id": 237217,
1835
1835
  "period": { "id": "2", "shortName": "", "longName": "2nd" },
1836
1836
  "time": "6:26",
1837
1837
  "againstTeam": {
@@ -1866,7 +1866,7 @@
1866
1866
  "isBench": false
1867
1867
  },
1868
1868
  {
1869
- "game_penalty_id": null,
1869
+ "game_penalty_id": 237227,
1870
1870
  "period": { "id": "2", "shortName": "", "longName": "2nd" },
1871
1871
  "time": "18:48",
1872
1872
  "againstTeam": {
@@ -2300,7 +2300,7 @@
2300
2300
  ],
2301
2301
  "penalties": [
2302
2302
  {
2303
- "game_penalty_id": null,
2303
+ "game_penalty_id": 237233,
2304
2304
  "period": { "id": "3", "shortName": "", "longName": "3rd" },
2305
2305
  "time": "4:35",
2306
2306
  "againstTeam": {
@@ -2335,7 +2335,7 @@
2335
2335
  "isBench": false
2336
2336
  },
2337
2337
  {
2338
- "game_penalty_id": null,
2338
+ "game_penalty_id": 237245,
2339
2339
  "period": { "id": "3", "shortName": "", "longName": "3rd" },
2340
2340
  "time": "13:27",
2341
2341
  "againstTeam": {
@@ -2370,7 +2370,7 @@
2370
2370
  "isBench": false
2371
2371
  },
2372
2372
  {
2373
- "game_penalty_id": null,
2373
+ "game_penalty_id": 237262,
2374
2374
  "period": { "id": "3", "shortName": "", "longName": "3rd" },
2375
2375
  "time": "16:49",
2376
2376
  "againstTeam": {
@@ -2405,7 +2405,7 @@
2405
2405
  "isBench": false
2406
2406
  },
2407
2407
  {
2408
- "game_penalty_id": null,
2408
+ "game_penalty_id": 237268,
2409
2409
  "period": { "id": "3", "shortName": "", "longName": "3rd" },
2410
2410
  "time": "16:49",
2411
2411
  "againstTeam": {
@@ -47,8 +47,9 @@ module AhlScraper
47
47
  attr_reader(*ATTRIBUTES)
48
48
 
49
49
  def initialize(game_id, opts = {})
50
+ raw_data = GameDataFetcher.new(game_id).call
51
+ super(raw_data, opts)
50
52
  @game_id = game_id
51
- @raw_data = GameDataFetcher.new(game_id).call
52
53
  @raw_event_data = GameEventDataFetcher.new(game_id).call
53
54
  @season_type = opts[:season_type] || SeasonTypeFetcher.new(@raw_data[:details][:seasonId]).call
54
55
  end
@@ -224,7 +225,7 @@ module AhlScraper
224
225
  end
225
226
 
226
227
  def overtimes
227
- @overtimes ||= Array(@raw_data[:periods][3..-1]).map { |o| Games::Overtime.new(o, { regular_season: season_type == :regular }) }
228
+ @overtimes ||= Array(@raw_data[:periods][3..]).map { |o| Games::Overtime.new(o, { regular_season: season_type == :regular }) }
228
229
  end
229
230
 
230
231
  def overtime?
@@ -353,7 +354,7 @@ module AhlScraper
353
354
  end
354
355
 
355
356
  def set_current_game_time
356
- return if /Final/.match?(@raw_data[:details][:status])
357
+ return if @raw_data[:details][:final] == "1" || @raw_data[:details][:started] == "0"
357
358
 
358
359
  game_time = @raw_data[:details][:status].match(/\d{1,2}:\d{2}/).to_s
359
360
  return if game_time.empty?
@@ -2,52 +2,52 @@
2
2
 
3
3
  module AhlScraper
4
4
  class GameListItem < Resource
5
- def initialize(raw_data)
6
- @raw_data = raw_data
5
+ def initialize(raw_data, opts = {})
6
+ super(raw_data, opts)
7
7
  end
8
8
 
9
9
  def id
10
- @id ||= @raw_data[:row][:game_id].to_i
10
+ @id ||= @raw_data&.dig(:row, :game_id).to_i
11
11
  end
12
12
 
13
13
  def home_team_city
14
- @home_team_city ||= @raw_data[:row][:home_team_city]
14
+ @home_team_city ||= @raw_data&.dig(:row, :home_team_city)
15
15
  end
16
16
 
17
17
  def home_team_score
18
- @home_team_score ||= @raw_data[:row][:home_goal_count].to_i
18
+ @home_team_score ||= @raw_data&.dig(:row, :home_goal_count).to_i
19
19
  end
20
20
 
21
21
  def home_team_id
22
- @home_team_id ||= @raw_data[:prop][:home_team_city][:teamLink].to_i
22
+ @home_team_id ||= @raw_data&.dig(:prop, :home_team_city, :teamLink).to_i
23
23
  end
24
24
 
25
25
  def away_team_city
26
- @away_team_city ||= @raw_data[:row][:visiting_team_city]
26
+ @away_team_city ||= @raw_data&.dig(:row, :visiting_team_city)
27
27
  end
28
28
 
29
29
  def away_team_score
30
- @away_team_score ||= @raw_data[:row][:visiting_goal_count].to_i
30
+ @away_team_score ||= @raw_data&.dig(:row, :visiting_goal_count).to_i
31
31
  end
32
32
 
33
33
  def away_team_id
34
- @away_team_id ||= @raw_data[:prop][:visiting_team_city][:teamLink].to_i
34
+ @away_team_id ||= @raw_data&.dig(:prop, :visiting_team_city, :teamLink).to_i
35
35
  end
36
36
 
37
37
  def date
38
- @date ||= @raw_data[:row][:date_with_day]
38
+ @date ||= @raw_data&.dig(:row, :date_with_day)
39
39
  end
40
40
 
41
41
  def status
42
- @status ||= @raw_data[:row][:game_status]
42
+ @status ||= @raw_data&.dig(:row, :game_status)&.match(/am|pm/) ? "Not Started" : @raw_data&.dig(:row, :game_status)
43
43
  end
44
44
 
45
45
  def game_report_url
46
- @game_report_url ||= @raw_data[:prop][:game_report][:link]
46
+ @game_report_url ||= @raw_data&.dig(:prop, :game_report, :link)
47
47
  end
48
48
 
49
49
  def game_sheet_url
50
- @game_sheet_url ||= @raw_data[:prop][:game_sheet][:link]
50
+ @game_sheet_url ||= @raw_data&.dig(:prop, :game_sheet, :link)
51
51
  end
52
52
 
53
53
  def game_center_url
@@ -64,7 +64,7 @@ module AhlScraper
64
64
  end
65
65
 
66
66
  def status
67
- @status ||= @raw_data[:status]
67
+ @status ||= @raw_data[:started] == "0" ? @raw_data[:status].strip : @raw_data[:status]
68
68
  end
69
69
 
70
70
  def season_id
@@ -4,7 +4,7 @@ module AhlScraper
4
4
  module Games
5
5
  class Penalty < Resource
6
6
  def id
7
- @id ||= @raw_data.dig(:game_penalty_id)&.to_i
7
+ @id ||= @raw_data[:game_penalty_id]&.to_i
8
8
  end
9
9
 
10
10
  def number
@@ -78,7 +78,7 @@ module AhlScraper
78
78
  end
79
79
 
80
80
  def bench?
81
- @raw_data[:isPowerPlay]
81
+ @raw_data[:isBench]
82
82
  end
83
83
 
84
84
  def invalid?
@@ -49,7 +49,7 @@ module AhlScraper
49
49
  p1_sog: @opts[:shots].dig(0, home_team? ? :home : :away),
50
50
  p2_sog: @opts[:shots].dig(1, home_team? ? :home : :away),
51
51
  p3_sog: @opts[:shots].dig(2, home_team? ? :home : :away),
52
- ot_sog: @opts[:shots][3..-1]&.map { |ot| ot[home_team? ? :home : :away].to_i },
52
+ ot_sog: @opts[:shots][3..]&.map { |ot| ot[home_team? ? :home : :away].to_i },
53
53
  }
54
54
  end
55
55
 
@@ -59,7 +59,7 @@ module AhlScraper
59
59
  p1_goals: @opts[:goal_totals].dig(0, home_team? ? :home : :away),
60
60
  p2_goals: @opts[:goal_totals].dig(1, home_team? ? :home : :away),
61
61
  p3_goals: @opts[:goal_totals].dig(2, home_team? ? :home : :away),
62
- ot_goals: @opts[:goal_totals][3..-1]&.map { |ot| ot[home_team? ? :home : :away].to_i },
62
+ ot_goals: @opts[:goal_totals][3..]&.map { |ot| ot[home_team? ? :home : :away].to_i },
63
63
  }
64
64
  end
65
65
 
@@ -2,7 +2,8 @@
2
2
 
3
3
  module AhlScraper
4
4
  class GoalieGameListItem < Resource
5
- def initialize(raw_data)
5
+ def initialize(raw_data, opts = {})
6
+ super(raw_data, opts)
6
7
  @raw_data = raw_data
7
8
  end
8
9
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  module AhlScraper
4
4
  class Player < Resource
5
- def initialize(raw_data)
6
- @raw_data = raw_data
5
+ def initialize(raw_data, opts = {})
6
+ super(raw_data, opts)
7
7
  end
8
8
 
9
9
  def id
@@ -2,20 +2,20 @@
2
2
 
3
3
  module AhlScraper
4
4
  class PlayoffBracket < Resource
5
- def initialize(bracket_data)
6
- @bracket_data = bracket_data
5
+ def initialize(raw_data, opts = {})
6
+ super(raw_data, opts)
7
7
  end
8
8
 
9
9
  def teams
10
- @teams ||= @bracket_data[:teams].map { |_team_id, team_data| PlayoffBrackets::Team.new(team_data) }
10
+ @teams ||= @raw_data[:teams].map { |_team_id, team_data| PlayoffBrackets::Team.new(team_data) }
11
11
  end
12
12
 
13
13
  def rounds
14
- @rounds ||= @bracket_data[:rounds].map { |round| PlayoffBrackets::Round.new(round) }
14
+ @rounds ||= @raw_data[:rounds].map { |round| PlayoffBrackets::Round.new(round, { raw_data: @raw_data }) }
15
15
  end
16
16
 
17
17
  def logo_url
18
- @logo_url ||= @bracket_data[:logo]
18
+ @logo_url ||= @raw_data[:logo]
19
19
  end
20
20
  end
21
21
  end
@@ -24,7 +24,7 @@ module AhlScraper
24
24
  end
25
25
 
26
26
  def series
27
- @series ||= @raw_data[:matchups].map { |series| Series.new(series) }
27
+ @series ||= @raw_data[:matchups].map { |series| Series.new(series, { bracket_data: @opts[:bracket_data] }) }
28
28
  end
29
29
  end
30
30
  end
@@ -3,6 +3,18 @@
3
3
  module AhlScraper
4
4
  module PlayoffBrackets
5
5
  class Series < Resource
6
+ OVERRIDE_WINS_NEEDED = {
7
+ "36" => { "1" => 4 },
8
+ "39" => { "1" => 4 },
9
+ "33" => { "1" => 4 },
10
+ "29" => { "1" => 4 },
11
+ "15" => { "1" => 4 },
12
+ "10" => { "1" => 4 },
13
+ "7" => { "1" => 4 },
14
+ "69" => { "1" => 4 },
15
+ "72" => { "1" => 1, "2" => 1, "3" => 2, "4" => 2 },
16
+ }.freeze
17
+
6
18
  def id
7
19
  @id ||= @raw_data[:series_letter]
8
20
  end
@@ -20,54 +32,82 @@ module AhlScraper
20
32
  end
21
33
 
22
34
  def active?
23
- @active ||= @raw_data[:active] == "1"
35
+ @active ||= @raw_data[:active] == "1" && team1_wins < wins_needed && team2_wins < wins_needed
24
36
  end
25
37
 
26
- def feeder_series1
27
- @feeder_series1 ||= @raw_data[:feeder_series1]
38
+ def home_feeder_series
39
+ @home_feeder_series ||= home_team_id == team1 ? @raw_data[:feeder_series1] : @raw_data[:feeder_series2]
28
40
  end
29
41
 
30
- def feeder_series2
31
- @feeder_series2 ||= @raw_data[:feeder_series2]
42
+ def away_feeder_series
43
+ @away_feeder_series ||= home_team_id == team1 ? @raw_data[:feeder_series2] : @raw_data[:feeder_series1]
32
44
  end
33
45
 
34
- def team1
35
- @team1 ||= @raw_data[:team1].to_i
46
+ def winning_team_id
47
+ @winning_team_id ||= @raw_data[:winner].empty? ? find_winner : @raw_data[:winner].to_i
36
48
  end
37
49
 
38
- def team2
39
- @team2 ||= @raw_data[:team2].to_i
50
+ def home_team_id
51
+ @home_team_id ||= first_game[:home_team].to_i
40
52
  end
41
53
 
42
- def team1_wins
43
- @team1_wins ||= @raw_data[:team1_wins]
54
+ def away_team_id
55
+ @away_team_id ||= first_game[:visiting_team].to_i
44
56
  end
45
57
 
46
- def team2_wins
47
- @team2_wins ||= @raw_data[:team2_wins]
58
+ def home_team_wins
59
+ @home_team_wins ||= home_team_id == team1 ? team1_wins : team2_wins
48
60
  end
49
61
 
50
- def winning_team
51
- @winning_team ||= @raw_data[:winner].empty? ? nil : @raw_data[:winner].to_i
62
+ def away_team_wins
63
+ @away_team_wins ||= home_team_id == team1 ? team2_wins : team1_wins
52
64
  end
53
65
 
54
66
  def ties
55
- @ties ||= @raw_data[:ties]
56
- end
57
-
58
- def home_team_id
59
- @home_team_id ||= first_game[:home_team].to_i
67
+ @ties ||= @raw_data[:ties].to_i
60
68
  end
61
69
 
62
70
  def games
63
71
  @games ||= @raw_data[:games].map { |game| Game.new(game) }
64
72
  end
65
73
 
74
+ def wins_needed
75
+ @wins_needed ||= OVERRIDE_WINS_NEEDED.dig(season_id, round.to_s) || (round == 1 ? 3 : 4)
76
+ end
77
+
66
78
  private
67
79
 
68
80
  def first_game
69
81
  @first_game ||= @raw_data[:games][0]
70
82
  end
83
+
84
+ def find_winner
85
+ return team1 if team1_wins == wins_needed
86
+
87
+ return team2 if team2_wins == wins_needed
88
+
89
+ nil
90
+ end
91
+
92
+ def season_id
93
+ @opts[:bracket_data]&.dig(:rounds, round - 1, :season_id)
94
+ end
95
+
96
+ def team1
97
+ @team1 ||= @raw_data[:team1].to_i
98
+ end
99
+
100
+ def team2
101
+ @team2 ||= @raw_data[:team2].to_i
102
+ end
103
+
104
+ def team1_wins
105
+ @team1_wins ||= @raw_data[:team1_wins]
106
+ end
107
+
108
+ def team2_wins
109
+ @team2_wins ||= @raw_data[:team2_wins]
110
+ end
71
111
  end
72
112
  end
73
113
  end
@@ -5,7 +5,7 @@ module AhlScraper
5
5
  attr_reader :team_id, :season_id
6
6
 
7
7
  def initialize(raw_data, team_id, season_id)
8
- @raw_data = raw_data
8
+ super(raw_data, {})
9
9
  @team_id = team_id
10
10
  @season_id = season_id
11
11
  end
@@ -4,7 +4,8 @@ module AhlScraper
4
4
  class Season < Resource
5
5
  attr_reader :id, :name, :season_type
6
6
 
7
- def initialize(raw_data)
7
+ def initialize(raw_data, opts = {})
8
+ super(raw_data, opts)
8
9
  @id = raw_data[:id].to_i
9
10
  @name = raw_data[:name]
10
11
  @season_type = set_season_type
@@ -15,13 +16,15 @@ module AhlScraper
15
16
  @abbreviation ||=
16
17
  case season_type
17
18
  when :regular
18
- "#{start_year.to_s[-2..-1]}-#{end_year.to_s[-2..-1]}"
19
+ "#{start_year.to_s[-2..]}-#{end_year.to_s[-2..]}"
19
20
  when :playoffs
20
- "#{start_year.to_s[-2..-1]}PO"
21
+ "#{start_year.to_s[-2..]}PO"
21
22
  when :all_star_game
22
- "#{start_year.to_s[-2..-1]}ASG"
23
+ "#{start_year.to_s[-2..]}ASG"
23
24
  when :exhibition
24
- "#{start_year.to_s[-2..-1]}-#{end_year.to_s[-2..-1]}EX"
25
+ "#{start_year.to_s[-2..]}-#{end_year.to_s[-2..]}EX"
26
+ when :preseason
27
+ "#{start_year.to_s[-2..]}PS"
25
28
  end
26
29
  end
27
30
 
@@ -29,8 +32,8 @@ module AhlScraper
29
32
  @start_year ||=
30
33
  case season_type
31
34
  when :regular, :exhibition
32
- name[/(.*?)\-/].to_i
33
- when :playoffs, :all_star_game
35
+ name[/(.*?)-/].to_i
36
+ when :playoffs, :all_star_game, :preseason
34
37
  name[/(.*?) /].to_i
35
38
  end
36
39
  end
@@ -48,7 +51,7 @@ module AhlScraper
48
51
  case season_type
49
52
  when :regular, :exhibition
50
53
  start_year + 1
51
- when :playoffs, :all_star_game
54
+ when :playoffs, :all_star_game, :preseason
52
55
  start_year
53
56
  end
54
57
  end
@@ -73,6 +76,8 @@ module AhlScraper
73
76
  :playoffs
74
77
  when /Regular/
75
78
  :regular
79
+ when /Preseason/
80
+ :preseason
76
81
  end
77
82
  end
78
83
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  module AhlScraper
4
4
  class SeasonListItem < Resource
5
- def initialize(raw_data)
6
- @raw_data = raw_data
5
+ def initialize(raw_data, opts = {})
6
+ super(raw_data, opts)
7
7
  end
8
8
 
9
9
  def id
@@ -28,8 +28,8 @@ module AhlScraper
28
28
  "henderson-silver-knights" => { city: "Henderson", name: "Silver Knights" },
29
29
  }.freeze
30
30
 
31
- def initialize(raw_data, division)
32
- @raw_data = raw_data
31
+ def initialize(raw_data, division, opts = {})
32
+ super(raw_data, opts)
33
33
  @division = division
34
34
  end
35
35
 
@@ -42,7 +42,8 @@ module AhlScraper
42
42
  end
43
43
 
44
44
  def abbreviation
45
- @abbreviation ||= EXCEPTIONS[parameterized_name]&.dig(:abbreviation) || @raw_data.dig(:row, :team_code)&.delete_prefix("y -")&.delete_prefix("x -")&.delete_prefix("xy -")&.strip
45
+ @abbreviation ||= EXCEPTIONS[parameterized_name]&.dig(:abbreviation) || @raw_data.dig(:row,
46
+ :team_code)&.delete_prefix("y -")&.delete_prefix("x -")&.delete_prefix("xy -")&.strip
46
47
  end
47
48
 
48
49
  def parameterized_name
@@ -2,8 +2,8 @@
2
2
 
3
3
  module AhlScraper
4
4
  class SkaterGameListItem < Resource
5
- def initialize(raw_data)
6
- @raw_data = raw_data
5
+ def initialize(raw_data, opts = {})
6
+ super(raw_data, opts)
7
7
  end
8
8
 
9
9
  def game_id
@@ -2,9 +2,8 @@
2
2
 
3
3
  module AhlScraper
4
4
  class TeamGameListItem < Resource
5
- def initialize(raw_data, opts)
6
- @raw_data = raw_data
7
- @opts = opts
5
+ def initialize(raw_data, opts = {})
6
+ super(raw_data, opts)
8
7
  end
9
8
 
10
9
  def game_id
@@ -5,7 +5,7 @@ module AhlScraper
5
5
  attr_reader :season_id
6
6
 
7
7
  def initialize(raw_data, season_id)
8
- @raw_data = raw_data
8
+ super(raw_data, {})
9
9
  @season_id = season_id
10
10
  end
11
11
 
@@ -3,7 +3,7 @@
3
3
  module AhlScraper
4
4
  module Games
5
5
  class CreateSkatersService
6
- def initialize(skater_data, goal_data, penalty_data, shootout_data, penalty_shot_data, opts)
6
+ def initialize(skater_data, goal_data, penalty_data, shootout_data, penalty_shot_data, opts = {})
7
7
  @skater_data = skater_data
8
8
  @goal_data = goal_data
9
9
  @penalty_data = penalty_data
@@ -45,7 +45,7 @@ module AhlScraper
45
45
  on_scoring_team ? "#{skater_ids.length}v#{opposing_skater_ids.length}" : "#{opposing_skater_ids.length}v#{skater_ids.length}"
46
46
  end
47
47
 
48
- def find_goal_situation(goal, on_scoring_team)
48
+ def find_goal_situation(goal, on_scoring_team) # rubocop:disable Metrics/CyclomaticComplexity
49
49
  return "pp" if (goal[:properties][:isPowerPlay] == "1" && on_scoring_team) || (goal[:properties][:isShortHanded] == "1" && !on_scoring_team)
50
50
 
51
51
  return "sh" if goal[:properties][:isShortHanded] == "1" && on_scoring_team || (goal[:properties][:isPowerPlay] == "1" && !on_scoring_team)