Module: ViewsHelpers
- Included in:
- InvoicesView, LineItemsView
- Defined in:
- lib/invoices/views/helpers/views_helper.rb
Instance Method Summary collapse
- #compare_length(string, max_length) ⇒ Object
- #divider ⇒ Object
- #format_hrs(h) ⇒ Object
- #format_rate(amt) ⇒ Object
Instance Method Details
#compare_length(string, max_length) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/invoices/views/helpers/views_helper.rb', line 2 def compare_length(string, max_length) # raise error if string.length < 0 || string.length > max_length string = string.to_s unless string.instance_of?(String) if string.length < max_length difference = 0 difference = max_length - string.length string + (" " * difference) else string end end |
#divider ⇒ Object
19 20 21 |
# File 'lib/invoices/views/helpers/views_helper.rb', line 19 def divider " | " end |
#format_hrs(h) ⇒ Object
13 14 15 |
# File 'lib/invoices/views/helpers/views_helper.rb', line 13 def format_hrs(h) compare_length(h, 3) end |
#format_rate(amt) ⇒ Object
16 17 18 |
# File 'lib/invoices/views/helpers/views_helper.rb', line 16 def format_rate(amt) compare_length("$" + amt.to_s, 4) end |