Sha256: f642627b942199a8956546a55400c295697cb6bcbf6caf55e38c2faa6db8d060

Contents?: true

Size: 368 Bytes

Versions: 2

Compression:

Stored size: 368 Bytes

Contents

module Faker
  module CreditCard
    class Visa
      extend Generator

      PREFIX  = "4"
      LENGTHS = [13, 16]

      def self.number(options = {})
        length = options.fetch(:length, LENGTHS.sample)
        fail "visa credit card can't have #{length} digits" unless LENGTHS.member? length
        generate_number(PREFIX, length)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
faker_credit_card-0.0.2 lib/faker_credit_card/visa.rb
faker_credit_card-0.0.1 lib/faker_credit_card/visa.rb