Sha256: 222b2987f1a6f5f58caba699e32824221e90507cb5f04defa2d50be102c6adc7

Contents?: true

Size: 961 Bytes

Versions: 6

Compression:

Stored size: 961 Bytes

Contents

module Wco::ApplicationHelper

  def my_truthy? which
    ["1", "t", "T", "true"].include?( which )
  end

  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.default_url_options[:host],
    })
  end

  def pretty_date date
    # date.to_s[0, 10]
    date&.strftime('%Y-%m-%d')
  end
  def pp_date a; pretty_date a; end

  def pp_datetime date
    date&.strftime('%Y-%m-%d %l:%M%P %z')
  end

  def pp_time date
    return nil if !date
    # return date.strftime('%l:%M%P %z')
    return date.in_time_zone( Rails.application.config.time_zone ).strftime('%l:%M%P %Z')
  end

  def pp_amount a
    return '-' if !a
    "$ #{'%.2f' % a}"
  end
  def pp_money a; pp_amount a; end
  def pp_currency a; pp_amount a; end
  def pp_percent a
    "#{(a*100).round(2)}%"
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
wco_models-3.1.0.70 app/helpers/wco/application_helper.rb
wco_models-3.1.0.69 app/helpers/wco/application_helper.rb
wco_models-3.1.0.67 app/helpers/wco/application_helper.rb
wco_models-3.1.0.66 app/helpers/wco/application_helper.rb
wco_models-3.1.0.65 app/helpers/wco/application_helper.rb
wco_models-3.1.0.64 app/helpers/wco/application_helper.rb