Module: LoiParser::Helpers

Defined in:
lib/loi_parser/helpers.rb

Overview

This module contain various helper methods

Class Method Summary collapse

Class Method Details

.elapsed_time(elapsed) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/loi_parser/helpers.rb', line 8

def self.elapsed_time(elapsed)
  if elapsed < 1
    "#{(elapsed * 1000).to_i} ms"
  elsif elapsed <= 60
    "#{elapsed.to_i} seconds"
  else
    min, sec = elapsed.divmod(60)

    "#{min} minutes #{sec.to_i} seconds"
  end
end

.formatted_thousands(number) ⇒ Object

1000 #=> 1,000



21
22
23
# File 'lib/loi_parser/helpers.rb', line 21

def self.formatted_thousands(number)
  number.to_s.gsub(/\B(?=(...)*\b)/, ',')
end