Class: AhlScraper::ElapsedTimeHelper
- Inherits:
-
Object
- Object
- AhlScraper::ElapsedTimeHelper
- Defined in:
- lib/ahl_scraper/helpers/elapsed_time_helper.rb
Instance Attribute Summary collapse
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
-
#initialize(time) ⇒ ElapsedTimeHelper
constructor
A new instance of ElapsedTimeHelper.
- #to_minutes ⇒ Object (also: #to_min)
- #to_minutes_with_period ⇒ Object (also: #to_min_with_per)
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
#time ⇒ Object (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_minutes ⇒ Object 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_period ⇒ Object 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 |