Sha256: 9df7bb7e21c5ff3b2789c5f9f1d3e0948d13cec84beb6233a4e2df9f320ffc00

Contents?: true

Size: 568 Bytes

Versions: 39

Compression:

Stored size: 568 Bytes

Contents

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module CreditCardFormatting

      # This method is used to format numerical information pertaining to credit cards.
      #
      #   format(2005, :two_digits)  # => "05"
      #   format(05,   :four_digits) # => "0005"
      def format(number, option)
        return '' if number.blank?

        case option
          when :two_digits  ; sprintf("%.2i", number.to_i)[-2..-1]
          when :four_digits ; sprintf("%.4i", number.to_i)[-4..-1]
          else number
        end
      end

    end
  end
end

Version data entries

39 entries across 39 versions & 2 rubygems

Version Path
tanga_activemerchant-1.38.0.5 lib/active_merchant/billing/credit_card_formatting.rb
tanga_activemerchant-1.38.0.4 lib/active_merchant/billing/credit_card_formatting.rb
tanga_activemerchant-1.38.0.3 lib/active_merchant/billing/credit_card_formatting.rb
tanga_activemerchant-1.38.0.2 lib/active_merchant/billing/credit_card_formatting.rb
tanga_activemerchant-1.38.0.1 lib/active_merchant/billing/credit_card_formatting.rb
tanga_activemerchant-1.38.0 lib/active_merchant/billing/credit_card_formatting.rb
tanga_activemerchant-1.37.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.43.3 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.43.1 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.43.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.42.9 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.42.8 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.42.7 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.42.6 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.42.5 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.42.4 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.42.3 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.42.2 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.42.1 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.42.0 lib/active_merchant/billing/credit_card_formatting.rb