We Recommend

Beginning Ruby: From Novice to Professional Beginning Ruby: From Novice to Professional
Beginning Ruby is a thoroughly contemporary guide for every type of reader wanting to learn Ruby, from novice programmers to web developers to Ruby newcomers. It starts by explaining the principles behind object-oriented programming and within a few chapters builds toward creating a genuine Ruby application.


Posted By

chrisaiv on 10/21/07


Tagged

ruby validation


Versions (?)


Who likes this?

5 people have marked this snippet as a favorite

edwinjanmoss
mehlam2
usharf
acookinc
inkdeep


Validate a Credit Card Number


Published in: Ruby 


Download the Credit Card Library from Lucas Carlson user$ sudo gem install creditcard

  1. #Checksum Digit, there is an algorithm that checksum must match
  2. #A. Import the libraries
  3. require 'rubygems'
  4. require 'creditcard'
  5.  
  6. #B. Boolean test as to whether this number is a valid credit card
  7. puts '5276 4400 6542 1319'.creditcard?
  8.  
  9. #C. Check the type of credit card it is
  10. puts '5276 4400 6542 1319'.creditcard_type

Report this snippet 

You need to login to post a comment.