Sha256: 7f2b31ca0f0e4e5bb7d5f655c39803a402699149a533a200c442ce9615e033fd
Contents?: true
Size: 1.41 KB
Versions: 6
Compression:
Stored size: 1.41 KB
Contents
= Conversions Unit conversion: 1.miles.to(:kilometres) #=> 1.609344 1.pounds.to(:kilograms) #=> 0.453592 1.pounds.to(:kilograms, 2) #=> 0.45 Or, more explicitly, 1.convert(:miles, :kilometres) #=> 1.609344 1.convert(:pounds, :kilograms) #=> 0.453592 1.convert(:pounds, :kilograms, :scale => 2) #=> 0.45 You can register your own conversions: Conversions.register(:miles, :nautical_miles, 0.868976242) 1.miles.to(:nautical_miles) #=> 0.868976242 It also adds a class method to ActiveRecord::Base that allows you to define conversion methods for attributes: class Car < ActiveRecord::Base conversion_accessor :weight, :internal => :kilograms, :external => :pounds end car = Car.new(:weight => 1500) car.weight_in_pounds #=> 3306.93393 car.weight_in_pounds = 3306 #=> 3306 == Installation === As a gem Configure the gem in environment.rb: config.gem 'Fingertips-conversions', :lib => 'conversions', :source => 'http://gems.github.com' Install them using Rails' rake task: $ rake gems:install === In your vendor directory: script/install plugin git://github.com/Fingertips/conversions.git
Version data entries
6 entries across 6 versions & 2 rubygems
Version | Path |
---|---|
seamusabshere-conversions-1.4.1 | README |
seamusabshere-conversions-1.4.2 | README |
conversions-1.4.6 | README |
conversions-1.4.5 | README |
conversions-1.4.4 | README |
conversions-1.4.3 | README |