No commit activity in last 3 years
No release in over 3 years
Because most percentages only need to be accurate to two decimals, this gem has you store them as basis points and does the conversion for you.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.0
~> 2.6

Runtime

 Project Readme

Installing

gem "acts_as_percentage"

Requirements

Rails 3.1.x

Usage

Allows you to store percent values as an integer.

class ProgressBar < ActiveRecord::Base
    percentage :completed
end

This assumes there is a column in the database named completed_basis_point (Integer). It creates several helper methods for you:

pb = ProgressBar.create(:completed => 59.87) # => <ProgressBar: @completed_basis_point=5987>
pb.completed # => 59.87
pb.completed_ratio # => 0.5987
pb.completed_basis_point # => 5987

Raises ArgumentError if the column specified is not present