Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/metaware/to_range
Small Ruby Gem to Convert Parseable Strings into Ruby Range Objects
https://github.com/metaware/to_range
Last synced: 1 day ago
JSON representation
Small Ruby Gem to Convert Parseable Strings into Ruby Range Objects
- Host: GitHub
- URL: https://github.com/metaware/to_range
- Owner: metaware
- License: mit
- Created: 2015-02-18T03:59:17.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-04-26T02:58:59.000Z (over 9 years ago)
- Last Synced: 2024-11-06T21:06:23.950Z (7 days ago)
- Language: Ruby
- Homepage:
- Size: 291 KB
- Stars: 10
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# to_range [![Code Climate](https://codeclimate.com/github/metaware/to_range/badges/gpa.svg)](https://codeclimate.com/github/metaware/to_range) [![Build Status](https://travis-ci.org/metaware/to_range.svg?branch=master)](https://travis-ci.org/metaware/to_range)
![to_range Logo](https://raw.github.com/metaware/to_range/master/to_range.png)
Ruby Gem to Convert strings (parsable) into Range Objects
## Usage
irb(main):001:0> "1..10".to_range
=> 1..10
=> PROFIT!For any ambiguous cases, where there might be multiple matches of a possible range, This library assumes you need only the first possible, valid-looking Range match, ex:
irb(main):001:0> "1.10..50..100".to_range
=> 10..50**PS: It blows on your face, if it's unable to find a possible parsable match.**
## TODO:
- Add support for Date/Time ranges? (Not in huge favor but if there's interest, I can take a stab at it.)
## Installation
Add this line to your application's Gemfile:
gem 'to_range'
And then execute:
$ bundle
Or install it yourself as:
$ gem install to_range
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request