Project

to_range

0.0
No commit activity in last 3 years
No release in over 3 years
Gem to parse Range like strings to actual Range Objects
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
>= 0
 Project Readme

to_range Code Climate Build Status

to_range Logo

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