class AhlScraper::Games::Goalie
Public Instance Methods
birthdate()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 34 def birthdate @birthdate ||= valid_birthdate? ? @raw_data[:info][:birthDate] : nil end
captaincy()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 65 def captaincy nil end
current_age()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 38 def current_age @current_age ||= valid_birthdate? ? BirthdateHelper.new(birthdate).age_on_date(@opts[:game_date]) : nil end
first_name()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 10 def first_name @first_name ||= @raw_data[:info][:firstName] end
home_team()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 26 def home_team @home_team ||= @opts[:home_team] end
id()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 6 def id @id ||= @raw_data[:info][:id] end
jersey_number()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 18 def jersey_number @jersey_number ||= @raw_data[:info][:jerseyNumber] end
last_name()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 14 def last_name @last_name ||= @raw_data[:info][:lastName] end
penalty_shots()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 76 def penalty_shots @penalty_shots ||= { attempts_against: penalty_shot_data.size, goals_against: penalty_shot_data.filter { |attempt| attempt[:isGoal] == true }.size, } end
position()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 30 def position @position ||= @raw_data[:info][:position] end
shootout()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 69 def shootout @shootout ||= { attempts_against: shootout_data.size, goals_against: shootout_data.filter { |attempt| attempt[:isGoal] == true }.size, } end
starting()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 57 def starting @starting ||= @raw_data[:starting] end
stats()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 42 def stats @stats ||= { goals: @raw_data[:stats][:goals], assists: @raw_data[:stats][:assists], points: @raw_data[:stats][:points], penalty_minutes: @raw_data[:stats][:penaltyMinute], toi: @raw_data[:stats][:timeOnIce], toi_in_seconds: set_time_on_ice_in_seconds, shots_against: @raw_data[:stats][:shotsAgainst], goals_against: @raw_data[:stats][:goalsAgainst], saves: @raw_data[:stats][:saves], save_percent: @raw_data[:stats][:shotsAgainst].positive? ? set_save_percent : nil, } end
status()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 61 def status @status ||= @raw_data[:status] end
team_id()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 22 def team_id @team_id ||= @opts[:team_id] end
Private Instance Methods
penalty_shot_data()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 97 def penalty_shot_data @penalty_shot_data ||= (@opts[:penalty_shot_data] || []).filter { |so| so[:goalie][:id] == id } end
set_save_percent()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 85 def set_save_percent BigDecimal(@raw_data[:stats][:shotsAgainst] - @raw_data[:stats][:goalsAgainst]) / @raw_data[:stats][:shotsAgainst] * 100 end
set_time_on_ice_in_seconds()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 89 def set_time_on_ice_in_seconds @raw_data[:stats][:timeOnIce].nil? ? nil : IceTimeHelper.new(@raw_data[:stats][:timeOnIce]).to_sec end
shootout_data()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 93 def shootout_data @shootout_data ||= (@opts[:shootout_data] || []).filter { |so| so[:goalie][:id] == id } end
valid_birthdate?()
click to toggle source
# File lib/ahl_scraper/resources/games/goalie.rb, line 101 def valid_birthdate? @valid_birthdate ||= !@raw_data.dig(:info, :birthDate).empty? && @raw_data.dig(:info, :birthDate) != "0000-00-00" end