Sha256: 24e1f6c497c181141817e455c989fb07e69b7e4cb421a0367cb1ea28293b2cc4

Contents?: true

Size: 700 Bytes

Versions: 38

Compression:

Stored size: 700 Bytes

Contents

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module CreditCardFormatting
      def expdate(credit_card)
        "#{format(credit_card.month, :two_digits)}#{format(credit_card.year, :two_digits)}"
      end

      # 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  then sprintf('%.2i', number.to_i)[-2..-1]
        when :four_digits then sprintf('%.4i', number.to_i)[-4..-1]
        else number
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 2 rubygems

Version Path
activemerchant-1.121.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.120.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.119.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.118.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.117.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.116.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.114.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.113.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.112.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.111.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.110.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.109.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.108.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.107.4 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.107.3 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.107.2 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.107.1 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.106.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.105.0 lib/active_merchant/billing/credit_card_formatting.rb
activemerchant-1.104.0 lib/active_merchant/billing/credit_card_formatting.rb