Sha256: 1d2ea3162d54682fd612ea126ded6ce900bada10f8fc0134a8fd6f5718b81675

Contents?: true

Size: 958 Bytes

Versions: 26

Compression:

Stored size: 958 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')
  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

26 entries across 26 versions & 1 rubygems

Version Path
wco_models-3.1.0.63 app/helpers/wco/application_helper.rb
wco_models-3.1.0.62 app/helpers/wco/application_helper.rb
wco_models-3.1.0.61 app/helpers/wco/application_helper.rb
wco_models-3.1.0.60 app/helpers/wco/application_helper.rb
wco_models-3.1.0.59 app/helpers/wco/application_helper.rb
wco_models-3.1.0.58 app/helpers/wco/application_helper.rb
wco_models-3.1.0.57 app/helpers/wco/application_helper.rb
wco_models-3.1.0.56 app/helpers/wco/application_helper.rb
wco_models-3.1.0.55 app/helpers/wco/application_helper.rb
wco_models-3.1.0.54 app/helpers/wco/application_helper.rb
wco_models-3.1.0.53 app/helpers/wco/application_helper.rb
wco_models-3.1.0.52 app/helpers/wco/application_helper.rb
wco_models-3.1.0.51 app/helpers/wco/application_helper.rb
wco_models-3.1.0.50 app/helpers/wco/application_helper.rb
wco_models-3.1.0.49 app/helpers/wco/application_helper.rb
wco_models-3.1.0.48 app/helpers/wco/application_helper.rb
wco_models-3.1.0.47 app/helpers/wco/application_helper.rb
wco_models-3.1.0.46 app/helpers/wco/application_helper.rb
wco_models-3.1.0.45 app/helpers/wco/application_helper.rb
wco_models-3.1.0.44 app/helpers/wco/application_helper.rb