Determine if a value is in-bounds
gem install linesman
# Gemfile
gem 'linesman'
There's not really much to it. There is only one method: Linesman.within_bounds?
It takes an option hash and a block.
The options hash must contain at least one of the following:
- :exactly
- :min
- :max
The block should return a value that is comparable to the bounds specified in the options hash.
The method returns either true or false based on the given criteria.
Examples:
Linesman.within_bounds?(exactly: 1) {2 - 1} # => true
Linesman.within_bounds?(min: 1, max: 10) {1} # => true
Linesman.within_bounds?(min: 1) {0} # => false
Linesman.within_bounds?(max: 1) {0} # => true
The actual library docs can be read over on rubydoc.
Do you use git-flow? I sure do. Please base anything you do off of the develop branch.
- Fork it.
- Perform some BDD magic. Seriously. Be testing.
- Submit a pull request.
In short, I've been needing this exact functionality all over the place of late, and it was quick enough to just throw it together.
MIT License. Copyright 2013 Ess