Sha256: 90e775cd204c6bd22861e387de1f65892fde3a4659e41534e61e9444cb5ad532

Contents?: true

Size: 631 Bytes

Versions: 2

Compression:

Stored size: 631 Bytes

Contents

# frozen_string_literal: true

module KnapsackPro
  class Presenter
    class << self
      def global_time
        global_time = pretty_seconds(KnapsackPro.tracker.global_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

2 entries across 2 versions & 1 rubygems

Version Path
knapsack_pro-5.7.0 lib/knapsack_pro/presenter.rb
knapsack_pro-5.6.0 lib/knapsack_pro/presenter.rb