Ruby Gem to Convert strings (parsable) into Range Objects
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.
- Add support for Date/Time ranges? (Not in huge favor but if there's interest, I can take a stab at it.)
Add this line to your application's Gemfile:
gem 'to_range'
And then execute:
$ bundle
Or install it yourself as:
$ gem install to_range
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request