Module: Gricer::BaseHelper

Defined in:
app/helpers/gricer/base_helper.rb

Overview

A helper with some basic features for formating Gricer’s data

Instance Method Summary collapse

Instance Method Details

#format_percentage(value) ⇒ Object

Format a value as percentage

Examples:

ruby> format_percentage 0.4223

=> "42.23 %"


9
10
11
# File 'app/helpers/gricer/base_helper.rb', line 9

def format_percentage value
  '%3.2f %' % (value * 100)
end

#format_seconds(value) ⇒ Object

Format a value of seconds as time range

Examples:

ruby> format_seconds 102

=> "00:01:42"


18
19
20
# File 'app/helpers/gricer/base_helper.rb', line 18

def format_seconds value
  '%02d:%02d:%02d' % [(value/3600).floor,((value/60)%60).floor,(value%60)]
end