Class: Shushu::BasePresenter
- Inherits:
-
Object
- Object
- Shushu::BasePresenter
show all
- Defined in:
- lib/presenters/base_presenter.rb
Instance Method Summary
collapse
Instance Method Details
#add_commas(str) ⇒ Object
8
9
10
|
# File 'lib/presenters/base_presenter.rb', line 8
def add_commas(str)
str.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse
end
|
#date_range(s, f) ⇒ Object
20
21
22
|
# File 'lib/presenters/base_presenter.rb', line 20
def date_range(s, f)
s.strftime('%d %b %H:%M ') + " - " + f.strftime('%d %b %H:%M ')
end
|
#money(cents) ⇒ Object
4
5
6
|
# File 'lib/presenters/base_presenter.rb', line 4
def money(cents)
add_commas(pennies_to_dollar(cents.to_i))
end
|
#pennies_to_dollar(qty) ⇒ Object
12
13
14
|
# File 'lib/presenters/base_presenter.rb', line 12
def pennies_to_dollar(qty)
sprintf("%.2f", qty / 100.0)
end
|
#trunc_hours(hrs) ⇒ Object
16
17
18
|
# File 'lib/presenters/base_presenter.rb', line 16
def trunc_hours(hrs)
sprintf("%.3f", hrs)
end
|