Class: KnapsackPro::Presenter
- Inherits:
-
Object
- Object
- KnapsackPro::Presenter
- Defined in:
- lib/knapsack_pro/presenter.rb
Class Method Summary collapse
Class Method Details
.global_time(time = nil) ⇒ Object
6 7 8 9 10 |
# File 'lib/knapsack_pro/presenter.rb', line 6 def global_time(time = nil) time = KnapsackPro.tracker.global_time if time.nil? global_time = pretty_seconds(time) "Global test execution duration: #{global_time}" end |
.pretty_seconds(seconds) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/knapsack_pro/presenter.rb', line 12 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 |