Class: AhlScraper::Games::Team
Instance Method Summary
collapse
Methods inherited from Resource
#[], #each, #initialize, #inspect, #keys, #to_json, #values
Instance Method Details
#abbreviation ⇒ Object
22
23
24
|
# File 'lib/ahl_scraper/resources/games/team.rb', line 22
def abbreviation
@abbreviation ||= @raw_data[:info][:abbreviation]
end
|
#city ⇒ Object
14
15
16
|
# File 'lib/ahl_scraper/resources/games/team.rb', line 14
def city
@city ||= @raw_data[:info][:city]
end
|
#full_name ⇒ Object
10
11
12
|
# File 'lib/ahl_scraper/resources/games/team.rb', line 10
def full_name
@full_name ||= @raw_data[:info][:name]
end
|
#goal_stats ⇒ Object
56
57
58
59
60
61
62
63
64
|
# File 'lib/ahl_scraper/resources/games/team.rb', line 56
def goal_stats
@goal_stats ||= {
goals: @opts[:goal_totals].map { |period| period[home_team? ? :home : :away] }.reduce(:+),
p1_goals: @opts[:goal_totals].dig(0, home_team? ? :home : :away),
p2_goals: @opts[:goal_totals].dig(1, home_team? ? :home : :away),
p3_goals: @opts[:goal_totals].dig(2, home_team? ? :home : :away),
ot_goals: @opts[:goal_totals][3..]&.map { |ot| ot[home_team? ? :home : :away].to_i },
}
end
|
#home_team? ⇒ Boolean
30
31
32
|
# File 'lib/ahl_scraper/resources/games/team.rb', line 30
def home_team?
@home_team ||= @opts[:home_team]
end
|
#id ⇒ Object
6
7
8
|
# File 'lib/ahl_scraper/resources/games/team.rb', line 6
def id
@id ||= @raw_data[:info][:id]
end
|
#logo_url ⇒ Object
26
27
28
|
# File 'lib/ahl_scraper/resources/games/team.rb', line 26
def logo_url
@logo_url ||= @raw_data[:info][:logo]
end
|
#name ⇒ Object
18
19
20
|
# File 'lib/ahl_scraper/resources/games/team.rb', line 18
def name
@name ||= @raw_data[:info][:nickname] == @raw_data[:info][:city] ? parse_nickname : @raw_data[:info][:nickname]
end
|
#on_ice_stats ⇒ Object
66
67
68
|
# File 'lib/ahl_scraper/resources/games/team.rb', line 66
def on_ice_stats
@on_ice_stats ||= TeamOnIceGoalsService.new(id, @opts[:goals]).call
end
|
#shot_stats ⇒ Object
46
47
48
49
50
51
52
53
54
|
# File 'lib/ahl_scraper/resources/games/team.rb', line 46
def shot_stats
@shot_stats ||= {
sog: @opts[:shots].map { |period| period[home_team? ? :home : :away] }.reduce(:+),
p1_sog: @opts[:shots].dig(0, home_team? ? :home : :away),
p2_sog: @opts[:shots].dig(1, home_team? ? :home : :away),
p3_sog: @opts[:shots].dig(2, home_team? ? :home : :away),
ot_sog: @opts[:shots][3..]&.map { |ot| ot[home_team? ? :home : :away].to_i },
}
end
|
#stats ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/ahl_scraper/resources/games/team.rb', line 34
def stats
@stats ||= {
score: score,
hits: @raw_data[:stats][:hits],
power_play_goals: @raw_data[:stats][:powerPlayGoals],
power_play_opportunities: @raw_data[:stats][:powerPlayOpportunities],
goals: @raw_data[:stats][:goalCount],
penalty_minute_count: @raw_data[:stats][:penaltyMinuteCount],
infraction_count: @raw_data[:stats][:infractionCount],
}
end
|
#time_splits ⇒ Object
70
71
72
|
# File 'lib/ahl_scraper/resources/games/team.rb', line 70
def time_splits
@time_splits ||= TimeSplitsService.new(@opts[:goals], id, @opts[:current_state], @opts[:game_properties]).call
end
|