https://github.com/ess/linesman
Determine if a value is within given bounds
https://github.com/ess/linesman
Last synced: over 1 year ago
JSON representation
Determine if a value is within given bounds
- Host: GitHub
- URL: https://github.com/ess/linesman
- Owner: ess
- License: mit
- Created: 2014-09-15T22:52:53.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-09-15T23:04:49.000Z (over 11 years ago)
- Last Synced: 2025-02-04T04:53:02.056Z (over 1 year ago)
- Language: Ruby
- Size: 129 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE
Awesome Lists containing this project
README
## Linesman ##
Determine if a value is in-bounds
## Gem Setup ##
```ruby
gem install linesman
# Gemfile
gem 'linesman'
```
## How Do I Use This Thing? ##
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:
```ruby
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
```
## Formal Documentation ##
The actual library docs can be read
[over on rubydoc](http://rubydoc.info/gems/linesman/frames).
## Contributing ##
Do you use git-flow? I sure do. Please base anything you do off of
[the develop branch](https://github.com/ess/linesman/tree/develop).
1. Fork it.
2. Perform some BDD magic. Seriously. Be testing.
3. Submit a pull request.
## So, Uh, Why? ##
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.
## License ##
MIT License. Copyright 2013 Ess