Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Adds methods to Fixnum and String to generate and validate Luhn checksums

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rspec
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 Rakefile
Octocat-spinner-32 luhn.gemspec

Luhn Build Status

Adds methods to Numeric and String to generate and validate Luhn checksums.


Add this line to your application's Gemfile:

gem 'moeffju-luhn', :require => 'luhn'

And then execute:

$ bundle

Or install it yourself as:

$ gem install moeffju-luhn

The gem's name is 'luhn', so you need to require luhn.


Numeric (Fixnum, Bignum):

4100410382.luhn?  #=> true
410041038.luhn    #=> 2
410041038.luhn!   #=> 4100410382

4100410648.luhn?  #=> true
410041064.luhn    #=> 8
410041064.luhn!   #=> 4100410648

And for Strings:

'4 10041064 8'.luhn?  #=> true
'4 10041064'.luhn     #=> "8"
'4 10041064'.luhn!    #=> "4100410648"


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Make sure the specs pass / extend the specs
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request
Something went wrong with that request. Please try again.