Sha256: 24b2e80e71db85f8472acd40a2c45cd43e64b57cae03985b2f387a48d7141c13

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

# encoding: utf-8

module InvoiceBar
  module InvoiceBarHelper
    
    # Defines an active state of the navbar item according to
    # which controller is used.
    def active_for_controller(controller)
      if params[:controller].include? controller
        'active'
      end
    end
    
    # Format Czech (and a like) 5-digit-long postcode.
    def formatted_postcode(postcode)
      unless postcode.to_s.length == 5
        postcode
      end

      postcode.to_s.gsub(/^(\d\d\d)(\d\d)$/,'\\1 \\2')
    end
    
    # Format money values using FormattedMoney.
    # If specified, it uses a +currency_symbol+ in front of the amount.
    def formatted_amount(cents, currency_symbol='')
      begin 
        results = FormattedMoney.amount(cents)
      rescue
        results = cents
      end
      
      if currency_symbol.blank?
        results
      else
        "#{currency_symbol} #{results}"
      end
    end 
    
    def formatted_money(cents, currency_symbol='')
      formatted_amount(cents, currency_symbol='')
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
invoice_bar-0.0.6 app/helpers/invoice_bar/invoice_bar_helper.rb
invoice_bar-0.0.5 app/helpers/invoice_bar/invoice_bar_helper.rb
invoice_bar-0.0.4 app/helpers/invoice_bar/invoice_bar_helper.rb
invoice_bar-0.0.3 app/helpers/invoice_bar/invoice_bar_helper.rb
invoice_bar-0.0.2 app/helpers/invoice_bar/invoice_bar_helper.rb
invoice_bar-0.0.1 app/helpers/invoice_bar/invoice_bar_helper.rb