Class: AhlScraper::PeriodTimeHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/ahl_scraper/helpers/period_time_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time, period = nil) ⇒ PeriodTimeHelper

Returns a new instance of PeriodTimeHelper.



7
8
9
10
# File 'lib/ahl_scraper/helpers/period_time_helper.rb', line 7

def initialize(time, period = nil)
  @time = time
  @period = period.to_i
end

Instance Attribute Details

#periodObject (readonly)

Returns the value of attribute period.



5
6
7
# File 'lib/ahl_scraper/helpers/period_time_helper.rb', line 5

def period
  @period
end

#timeObject (readonly)

Returns the value of attribute time.



5
6
7
# File 'lib/ahl_scraper/helpers/period_time_helper.rb', line 5

def time
  @time
end

Instance Method Details

#to_period_secondsObject Also known as: to_sec



12
13
14
15
16
17
# File 'lib/ahl_scraper/helpers/period_time_helper.rb', line 12

def to_period_seconds
  return unless time

  period_time = time&.split(":")
  period_time[0].to_i * 60 + period_time[1].to_i
end

#to_time_elapsedObject Also known as: to_elapsed



19
20
21
22
23
24
# File 'lib/ahl_scraper/helpers/period_time_helper.rb', line 19

def to_time_elapsed
  return unless time

  period_time = time&.split(":")
  period_time[0].to_i * 60 + period_time[1].to_i + ((period - 1) * 1200)
end