Sha256: 86c8c18be62f6cda85db45b2e9526fe50b108c62245903f8c64d19c55909db35

Contents?: true

Size: 390 Bytes

Versions: 3

Compression:

Stored size: 390 Bytes

Contents

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module CreditCardFormatting
      def format(number, format)
        return '' if number.blank?
        
        case format
        when :two_digits
          sprintf("%.2i", number)[-2..-1]
        when :four_digits
          sprintf("%.4i", number)[-4..-1]
        else
          number
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activemerchant-1.2.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.1.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.2.1 lib/active_merchant/billing/credit_card_formatting.rb