Module: Wco::ApplicationHelper
- Included in:
- ApplicationController
- Defined in:
- app/helpers/wco/application_helper.rb
Instance Method Summary collapse
- #my_truthy?(which) ⇒ Boolean
- #obfuscate(link) ⇒ Object
- #pp_amount(a, config = { precision: 2 }) ⇒ Object
- #pp_currency(a) ⇒ Object
- #pp_date(a) ⇒ Object
- #pp_datetime(date) ⇒ Object
-
#pp_money(a) ⇒ Object
“$#% a”.
- #pp_percent(a, config = { precision: 2}) ⇒ Object
- #pp_time(date) ⇒ Object
- #pretty_date(date) ⇒ Object
Instance Method Details
#my_truthy?(which) ⇒ Boolean
4 5 6 |
# File 'app/helpers/wco/application_helper.rb', line 4 def my_truthy? which ["1", "t", "T", "true"].include?( which ) end |
#obfuscate(link) ⇒ Object
8 9 10 11 12 13 14 |
# File 'app/helpers/wco/application_helper.rb', line 8 def obfuscate link # puts! link, 'obfuscate helper' if DEBUG obf = WcoEmail::ObfuscatedRedirect.find_or_create_by({ to: link }) return WcoEmail::Engine.routes.url_helpers.obf_url( obf.id, { host: Rails.application.routes.[:host], }) end |
#pp_amount(a, config = { precision: 2 }) ⇒ Object
32 33 34 35 36 37 |
# File 'app/helpers/wco/application_helper.rb', line 32 def pp_amount a, config = { precision: 2 } return '-' if !a return '-' if a.class == String return number_to_currency a, precision: config[:precision] # "$#{'%.2f' % a}" end |
#pp_currency(a) ⇒ Object
39 |
# File 'app/helpers/wco/application_helper.rb', line 39 def pp_currency a; pp_amount a; end |
#pp_date(a) ⇒ Object
20 |
# File 'app/helpers/wco/application_helper.rb', line 20 def pp_date a; pretty_date a; end |
#pp_datetime(date) ⇒ Object
22 23 24 25 |
# File 'app/helpers/wco/application_helper.rb', line 22 def pp_datetime date return nil if !date return date.in_time_zone( Rails.application.config.time_zone ).strftime('%Y-%m-%d %l:%M%P %Z') end |
#pp_money(a) ⇒ Object
“$#% a”
38 |
# File 'app/helpers/wco/application_helper.rb', line 38 def pp_money a; pp_amount a; end |
#pp_percent(a, config = { precision: 2}) ⇒ Object
40 41 42 |
# File 'app/helpers/wco/application_helper.rb', line 40 def pp_percent a, config = { precision: 2} "#{(a*100).round( config[:precision] )}%" rescue '@TODO' end |
#pp_time(date) ⇒ Object
27 28 29 30 |
# File 'app/helpers/wco/application_helper.rb', line 27 def pp_time date return nil if !date return date.in_time_zone( Rails.application.config.time_zone ).strftime('%l:%M%P %Z') end |
#pretty_date(date) ⇒ Object
16 17 18 19 |
# File 'app/helpers/wco/application_helper.rb', line 16 def pretty_date date return nil if !date date.in_time_zone( Rails.application.config.time_zone ).strftime('%Y-%m-%d') end |