reciter

<img src=“https://secure.travis-ci.org/rodrigomanhaes/reciter.png”/> <img src=“https://gemnasium.com/rodrigomanhaes/reciter.png”/>

Parses number sequences in the form:

p.parse('1-3;5;9-11')

when “p” is an instance of Reciter::Parse, returning, for this case, the following array:

[1, 2, 3, 5, 9, 10, 11]

reciter also unparses an array to a human-readable sentence, when:

p.unparse(1, 2, 3, 5, 9, 10, 11)

returns:

"1 to 3, 5, 9 to 11"

An alternative text can be provided for replacing “to”:

Reciter::Parser.config.text_for_to = 'a'
p.unparse(1, 2, 3)     # "1 a 3"

It’s possible unparsing to “mechanical” form:

p.unparse(:mechanic, 1, 2, 3, 5, 9, 10, 11) # 1-3;5;9-11

How to install

Just run:

gem install reciter

Contributing to reciter

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet.

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it.

  • Fork the project.

  • Start a feature/bugfix branch.

  • Commit and push until you are happy with your contribution.

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2012 Rodrigo Manhães. See LICENSE.txt for further details.