peterhellberg / hashids.rb

A small Ruby gem to generate YouTube-like hashes from one or many numbers. Use hashids when you do not want to expose your database ids to the user.
http://www.hashids.org/ruby/
MIT License
975 stars 46 forks source link

explicitly uses .div instead of '/' #1

Closed jasonadamyoung closed 11 years ago

jasonadamyoung commented 11 years ago

I have a bit of an odd edge case. I have a few projects where I always "require 'mathn'" to essentially return more accurate Rational results from numeric calculations in those projects. Mathn overrides "/" to use #quo instead of #div - returning a Rational instead of a Fixnum

What this meant for hashids.rb is while number > 0 turned into an infinite loop, because numbers < alphabet.length never were 0.

Using .div works great, and I figured I'd pass it along for the incredibly rare individual in the world using both mathn and hashids.

peterhellberg commented 11 years ago

Sorry that it took so long, I apparently got a few pull requests that flew under my radar :(

I’ll cut a new gem pretty soon.

jasonadamyoung commented 11 years ago

No problem! I understand - thanks for the merge!