Sha256: 4312236a5978c5d5131f5ec94a24b51029a8aef94823b6656ce6778da160c5b2

Contents?: true

Size: 477 Bytes

Versions: 12

Compression:

Stored size: 477 Bytes

Contents

# frozen_string_literal: true

module AhlScraper
  class ElapsedTimeHelper
    attr_reader :time

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

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

    def to_minutes_with_period
      period_elapsed = time % 1200

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

    alias to_min to_minutes
    alias to_min_with_per to_minutes_with_period
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ahl_scraper-0.4.0 lib/ahl_scraper/helpers/elapsed_time_helper.rb
ahl_scraper-0.3.8 lib/ahl_scraper/helpers/elapsed_time_helper.rb
ahl_scraper-0.3.7 lib/ahl_scraper/helpers/elapsed_time_helper.rb
ahl_scraper-0.3.6 lib/ahl_scraper/helpers/elapsed_time_helper.rb
ahl_scraper-0.3.5 lib/ahl_scraper/helpers/elapsed_time_helper.rb
ahl_scraper-0.3.4 lib/ahl_scraper/helpers/elapsed_time_helper.rb
ahl_scraper-0.3.3 lib/ahl_scraper/helpers/elapsed_time_helper.rb
ahl_scraper-0.3.2 lib/ahl_scraper/helpers/elapsed_time_helper.rb
ahl_scraper-0.3.1 lib/ahl_scraper/helpers/elapsed_time_helper.rb
ahl_scraper-0.3.0 lib/ahl_scraper/helpers/elapsed_time_helper.rb
ahl_scraper-0.2.0 lib/ahl_scraper/helpers/elapsed_time_helper.rb
ahl_scraper-0.1.1 lib/ahl_scraper/helpers/elapsed_time_helper.rb