Class Index [+]

Quicksearch

RSpec::Core::Formatters::Helpers

Constants

SUB_SECOND_PRECISION
DEFAULT_PRECISION

Public Instance Methods

format_duration(duration) click to toggle source
    # File lib/rspec/core/formatters/helpers.rb, line 9
 9:         def format_duration(duration)
10:           if duration > 60
11:             minutes = duration.to_i / 60
12:             seconds = duration - minutes * 60
13: 
14:             "#{pluralize(minutes, 'minute')} #{format_seconds(seconds)} seconds"
15:           else
16:             "#{format_seconds(duration)} seconds"
17:           end
18:         end
format_seconds(float) click to toggle source
    # File lib/rspec/core/formatters/helpers.rb, line 20
20:         def format_seconds(float)
21:           precision ||= (float < 1) ? SUB_SECOND_PRECISION : DEFAULT_PRECISION
22:           formatted = sprintf("%.#{precision}f", float)
23:           strip_trailing_zeroes(formatted)
24:         end
pluralize(count, string) click to toggle source
    # File lib/rspec/core/formatters/helpers.rb, line 31
31:         def pluralize(count, string)
32:           "#{count} #{string}#{'s' unless count == 1}"
33:         end
strip_trailing_zeroes(string) click to toggle source
    # File lib/rspec/core/formatters/helpers.rb, line 26
26:         def strip_trailing_zeroes(string)
27:           stripped = string.sub(/[^1-9]+$/, '')
28:           stripped.empty? ? "0" : stripped
29:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.