Performance Plus Oil

Performance Plus Oil

Commercial Contractors

Commercial Contractors

Marushka Handprints

Marushka Handprints

CDCookie

CDCookie

Wheatley-Gaso

Wheatley-Gaso

D.R. Gillcrest

D.R. Gillcrest

Publishing my first gem

Posted by Torey Heinz on October 27, 2010

After many failed attempts to wrap my mind around creating a gem, I finally decided that I wasn't going to do anything else until I figured it out.

Part of the reason I had never done it until this point was because I had never "needed" to. Much of what I have learned about ruby has been through necessity (it's a great teacher I've heard). But this concept of creating gems was always in the back of my mind (I should really know how to do this, it can't be that hard). As it turns out it's not so bad thanks to Jeweler.

Now that I know how, I can see all kinds of ways to simplify and reuse my code. So what's this gem... nothing special, I decided to pull some code out of an initializer that added a to_html_fraction method to a float. I added some tests and some better rounding. If you have a number like 3.63 you can call to_html_fraction and get 3⅝.

You can find it here http://github.com/toreyheinz/to_html_fraction

What are your thoughts?