Sha256: 84f5c52e7a8e54997f23dd14544da4fb985f0598f8099eb4e154d007cbb51b80

Contents?: true

Size: 577 Bytes

Versions: 1

Compression:

Stored size: 577 Bytes

Contents

module MerbMerchant #: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)[-2..-1]
          when :four_digits ; sprintf("%.4i", number)[-4..-1]
          else number
        end
      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
merb_merchant-1.4.1 lib/merb_merchant/billing/credit_card_formatting.rb