Project

agery

0.0
No commit activity in last 3 years
No release in over 3 years
Integer extensions for generating arrays of ages.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

 Project Readme

Agery

Agery is a set of extensions to Ruby's Integer class to assist developers in generating arrays of ages. It's similar to ActiveSupport's extensions for calculating bytes (1.megabyte) or durations (3.days). It's designed to help generate data used when pricing is dependent upon age.

For example, a movie ticket may cost $13.99 for an adult, $4.99 for a young child, $7.99 for a senior citizen, and free for infants. Also the movie may be rated for mature audiences and not permit teenagers without an adult.

Since the primary use case is for pricing calculations, adults are treated as an undefined age (-1) which would correspond to the most expensive price. Also children default to 0 to ensure they will trigger the least expensive price.

Examples

1.adult #=> [-1]
3.teenagers #=> [13, 13, 13]
2.infants #=> [0, 0]
0.children #=> []
2.seniors #=> [65, 65]
2.adults + 1.child #=> [-1, -1, 0]
1.over_21 #=> [21]
2.under_18 #=> [17, 17]

Customization

You can override Agery's concept of the age of an adult, infant, child, teenager, and senior by setting the Agery accessor of the same name.

Agery.adult = 18
2.adults #=> [18, 18]

Installation

$ gem install agery