Sha256: d9e0abbadf20a3f29718ef20f93bf4bcc8a04d54a953120734fc2a78074bcc38

Contents?: true

Size: 676 Bytes

Versions: 5

Compression:

Stored size: 676 Bytes

Contents

# frozen_string_literal: true

module KnapsackPro
  class Presenter
    class << self
      def global_time(time = nil)
        time = KnapsackPro.tracker.global_time if time.nil?
        global_time = pretty_seconds(time)
        "Global time execution for tests: #{global_time}"
      end

      def pretty_seconds(seconds)
        sign = ''

        if seconds < 0
          seconds = seconds*-1
          sign = '-'
        end

        return "#{sign}#{seconds}s" if seconds.abs < 1

        time = Time.at(seconds).gmtime.strftime('%Hh %Mm %Ss')
        time_without_zeros = time.gsub(/00(h|m|s)/, '').strip
        sign + time_without_zeros
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
knapsack_pro-6.0.4 lib/knapsack_pro/presenter.rb
knapsack_pro-6.0.3 lib/knapsack_pro/presenter.rb
knapsack_pro-6.0.2 lib/knapsack_pro/presenter.rb
knapsack_pro-6.0.1 lib/knapsack_pro/presenter.rb
knapsack_pro-6.0.0 lib/knapsack_pro/presenter.rb