Module: LazyFormat::Rails::ViewHelpers
- Defined in:
- lib/lazy_format/rails/helpers.rb
Instance Method Summary collapse
- #lazy_date(time) ⇒ Object
- #lazy_datetime(time) ⇒ Object
- #lazy_percentage(number, digit = 2) ⇒ Object
- #lazy_precision(number, digit = 2) ⇒ Object
Instance Method Details
#lazy_date(time) ⇒ Object
10 11 12 13 14 |
# File 'lib/lazy_format/rails/helpers.rb', line 10 def lazy_date(time) if time time.strftime("%Y-%m-%d") end end |
#lazy_datetime(time) ⇒ Object
4 5 6 7 8 |
# File 'lib/lazy_format/rails/helpers.rb', line 4 def lazy_datetime(time) if time time.strftime("%Y-%m-%d %H:%M") end end |
#lazy_percentage(number, digit = 2) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/lazy_format/rails/helpers.rb', line 16 def lazy_percentage number, digit = 2 if number.is_a? Numeric number_to_percentage(number * 100, precision: digit) else number_to_percentage(0, precision: digit) end end |
#lazy_precision(number, digit = 2) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/lazy_format/rails/helpers.rb', line 24 def lazy_precision number, digit = 2 if number.is_a? Numeric number_with_precision(number, precision: digit) else number_with_precision(0, precision: digit) end end |