class AhlScraper::Games::Team
Public Instance Methods
abbreviation()
click to toggle source
# File lib/ahl_scraper/resources/games/team.rb, line 22 def abbreviation @abbreviation ||= @raw_data[:info][:abbreviation] end
city()
click to toggle source
# File lib/ahl_scraper/resources/games/team.rb, line 14 def city @city ||= @raw_data[:info][:city] end
full_name()
click to toggle source
# File lib/ahl_scraper/resources/games/team.rb, line 10 def full_name @full_name ||= @raw_data[:info][:name] end
goal_stats()
click to toggle source
# 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..-1]&.map { |ot| ot[home_team? ? :home : :away].to_i }, } end
home_team?()
click to toggle source
# File lib/ahl_scraper/resources/games/team.rb, line 30 def home_team? @home_team ||= @opts[:home_team] end
id()
click to toggle source
# File lib/ahl_scraper/resources/games/team.rb, line 6 def id @id ||= @raw_data[:info][:id] end
logo_url()
click to toggle source
# File lib/ahl_scraper/resources/games/team.rb, line 26 def logo_url @logo_url ||= @raw_data[:info][:logo] end
name()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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..-1]&.map { |ot| ot[home_team? ? :home : :away].to_i }, } end
stats()
click to toggle source
# 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()
click to toggle source
# 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
Private Instance Methods
parse_nickname()
click to toggle source
# File lib/ahl_scraper/resources/games/team.rb, line 80 def parse_nickname @raw_data[:info][:name].gsub(@raw_data[:info][:nickname], "").strip end
score()
click to toggle source
# File lib/ahl_scraper/resources/games/team.rb, line 76 def score @score ||= @opts[:shootout] && @opts[:winning_team_id] == id ? @raw_data[:stats][:goals] + 1 : @raw_data[:stats][:goals] end