Skip to content

Small Ruby Gem to Convert Parseable Strings into Ruby Range Objects

License

Notifications You must be signed in to change notification settings

metaware/to_range

Repository files navigation

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

About

Small Ruby Gem to Convert Parseable Strings into Ruby Range Objects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published