Class: AhlScraper::ElapsedTimeHelper

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time) ⇒ ElapsedTimeHelper

Returns a new instance of ElapsedTimeHelper.



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

def initialize(time)
  @time = time.to_i
end

Instance Attribute Details

#timeObject (readonly)

Returns the value of attribute time.



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

def time
  @time
end

Instance Method Details

#to_minutesObject Also known as: to_min



11
12
13
# File 'lib/ahl_scraper/helpers/elapsed_time_helper.rb', line 11

def to_minutes
  "#{time / 60}:#{(time % 60).to_s.rjust(2, '0')}"
end

#to_minutes_with_periodObject Also known as: to_min_with_per



15
16
17
18
19
# File 'lib/ahl_scraper/helpers/elapsed_time_helper.rb', line 15

def to_minutes_with_period
  period_elapsed = time % 1200

  ["#{period_elapsed / 60}:#{period_elapsed % 60}", (time / 1200) + 1]
end