Class: AhlScraper::Games::Overtime

Inherits:
Resource
  • Object
show all
Defined in:
lib/ahl_scraper/resources/games/overtime.rb

Instance Method Summary collapse

Methods inherited from Resource

#[], #each, #initialize, #inspect, #keys, #to_json, #values

Constructor Details

This class inherits a constructor from AhlScraper::Resource

Instance Method Details

#away_goalsObject



39
40
41
# File 'lib/ahl_scraper/resources/games/overtime.rb', line 39

def away_goals
  @away_goals ||= @raw_data[:stats][:visitingGoals].to_i
end

#away_sogObject



43
44
45
# File 'lib/ahl_scraper/resources/games/overtime.rb', line 43

def away_sog
  @away_sog ||= @raw_data[:stats][:visitingShots].to_i
end

#home_goalsObject



31
32
33
# File 'lib/ahl_scraper/resources/games/overtime.rb', line 31

def home_goals
  @home_goals ||= @raw_data[:stats][:homeGoals].to_i
end

#home_sogObject



35
36
37
# File 'lib/ahl_scraper/resources/games/overtime.rb', line 35

def home_sog
  @home_sog ||= @raw_data[:stats][:homeShots].to_i
end

#lengthObject



14
15
16
# File 'lib/ahl_scraper/resources/games/overtime.rb', line 14

def length
  @length ||= ElapsedTimeHelper.new(length_in_seconds).to_min
end

#length_in_secondsObject



18
19
20
21
22
23
24
25
# File 'lib/ahl_scraper/resources/games/overtime.rb', line 18

def length_in_seconds
  @length_in_seconds ||=
    if scoring?
      PeriodTimeHelper.new(@raw_data[:goals][0][:time]).to_sec
    else
      @opts[:regular_season] ? 300 : 1200
    end
end

#nameObject



10
11
12
# File 'lib/ahl_scraper/resources/games/overtime.rb', line 10

def name
  @name ||= "#{@raw_data[:info][:longName]}#{number}"
end

#numberObject



6
7
8
# File 'lib/ahl_scraper/resources/games/overtime.rb', line 6

def number
  @number ||= @raw_data[:info][:id].to_i - 3
end

#scoring?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/ahl_scraper/resources/games/overtime.rb', line 27

def scoring?
  @scoring ||= @raw_data[:goals].any?
end