Sha256: ed3a91ee257065c1e659fcee017a71003419b084e96824498a61bcea3e9bb23f
Contents?: true
Size: 504 Bytes
Versions: 5
Compression:
Stored size: 504 Bytes
Contents
module Iz class CreditCard REGEX = /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/ attr_accessor :value def initialize(credit_card_number) self.value = credit_card_number end def valid? !!Iz::CreditCard.is_credit_card?(value) end def self.is_credit_card?(value) return false unless value value.to_s =~ REGEX end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
iz-0.3.1 | lib/iz/credit_card.rb |
iz-0.3.0 | lib/iz/credit_card.rb |
iz-0.2.1 | lib/iz/credit_card.rb |
iz-0.2.0 | lib/iz/credit_card.rb |
iz-0.1.0 | lib/iz/credit_card.rb |