Git Product home page Git Product logo

agery's Introduction

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

agery's People

Contributors

cgriego avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

agery's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.