Class: AhlScraper::PeriodTimeHelper
- Inherits:
-
Object
- Object
- AhlScraper::PeriodTimeHelper
- Defined in:
- lib/ahl_scraper/helpers/period_time_helper.rb
Instance Attribute Summary collapse
-
#period ⇒ Object
readonly
Returns the value of attribute period.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
-
#initialize(time, period = nil) ⇒ PeriodTimeHelper
constructor
A new instance of PeriodTimeHelper.
- #to_period_seconds ⇒ Object (also: #to_sec)
- #to_time_elapsed ⇒ Object (also: #to_elapsed)
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
#period ⇒ Object (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 |
#time ⇒ Object (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_seconds ⇒ Object 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_elapsed ⇒ Object 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 |