https://github.com/stephencelis/scantron
Rule-based string scanning and scrubbing.
https://github.com/stephencelis/scantron
Last synced: 3 months ago
JSON representation
Rule-based string scanning and scrubbing.
- Host: GitHub
- URL: https://github.com/stephencelis/scantron
- Owner: stephencelis
- Created: 2010-12-31T15:02:29.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2011-09-02T05:48:04.000Z (over 14 years ago)
- Last Synced: 2025-09-11T22:34:56.853Z (4 months ago)
- Language: Ruby
- Homepage:
- Size: 117 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
Awesome Lists containing this project
README
= Scantron
http://github.com/stephencelis/scantron
A simple, but powerful, rule-based string scanner and scrubber.
== Examples
==== NumberScanner
require "scantron"
require "number_scanner"
NumberScanner.scan "A one, 2, 3.0, 4 1/2..."
# => [1, 2, 3.0, (9/2)]
number_scanner = NumberScanner.new < [99, 99, 1, (197/2)]
puts number_scanner.scrub { |n| "#{n}" }
Ninety-nine bottles of beer on the wall.
Ninety-nine bottles of beer.
Take one down, pass it around,
Ninety-eight and a half bottles of beer on the wall.
==== RangeScanner
require "scantron"
require "range_scanner"
RangeScanner.scan "100-150 degrees"
# => [100..150]
RangeScanner.scan "Twelve or thirteen rolls for five or six people"
# => [12..13, 5..6]
=== Build Your Own
TODO
== Install
% [sudo] gem install scantron
Or, with {Bundler}[http://gembundler.com/], add gem "scantron" to your
Gemfile and run bundle install.
== License
(The MIT License)
(c) 2010 Stephen Celis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.