0.0
No commit activity in last 3 years
No release in over 3 years
Seamlessly store different types of values (such as dollars) as integers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

StoreAsInt

Seamlessly store and compare decimal based values as integers

gem install store_as_int

Usage

StoreAsInt::TypeToUse.new(value)
StoreAsInt.type_to_use(value)

Values passed to StoreAsInt can be a String, Numeric, Or Integer

If an Integer is passed directly to StoreAsInt, it is assumed that is the value that should be stored directly, and no conversion will take place

Built In Types

Money ($1.01)

decimals: 2 accuracy: 2 symbol: $

StoreAsInt::Money.new(value)
StoreAsInt.money(value)

ExchangeRate (%1.0000000001)

decimals: 4 accuracy: 10 symbol: %

StoreAsInt::ExchangeRate.new(value)
StoreAsInt.exchange_rate(value)

Register New Type

StoreAsInt.register(under_scored_class_name, base_value = 1 (i.e. 100 for dollars), number_of_decimals = 0, symbol_to_use = '', &block_to_use_for_to_s_formatting)

StoreAsInt::CamelCaseClassName.new(value)
StoreAsInt.under_scored_class_name(value)

Testing

bundle exec rspec