Home > ruler

ruler

Ruler is a project mainly written in Ruby, it's free.

Converts a float into a formatted string with approximate ruler measurements.

This code extends the Float class to enable pretty formatting of floats into approximate ruler measurements through the to_ruler method.

It automatically formats feet, inches, and fractions of an inch. The fractions are reduced using the largest common denominator with a maximum of 32nds of an inch.

Here are some examples:

puts 14.25.to_ruler 1' 2 1/4"

puts 1.to_f.to_ruler 1"

puts 132.48.to_ruler 11' 15/32"

puts 132.48.to_ruler(:base => 16) 11' 1/2"

Previous:CountIP