Sha256: fa8541758d8c4568b07f874cf2af22aaf8e38ae19c3b2e35d8f3c1e8c8c2ad49

Contents?: true

Size: 1.03 KB

Versions: 62

Compression:

Stored size: 1.03 KB

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
    return nil if !date
    date.in_time_zone( Rails.application.config.time_zone ).strftime('%Y-%m-%d')
  end
  def pp_date a; pretty_date a; end

  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

  def pp_time date
    return nil if !date
    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

62 entries across 62 versions & 1 rubygems

Version Path
wco_models-3.1.0.72 app/helpers/wco/application_helper.rb
wco_models-3.1.0.71 app/helpers/wco/application_helper.rb