Created
June 21, 2012 00:51
-
-
Save codatory/2963226 to your computer and use it in GitHub Desktop.
Ruby Class for creating a list of normalized strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'set' | |
| class CleanedList | |
| def initialize | |
| @data = SortedSet.new | |
| end | |
| def to_a | |
| @data.to_a | |
| end | |
| def to_set | |
| @data | |
| end | |
| def <<(item) | |
| processed = item.to_s.downcase.strip.gsub(/\s{2,}/, '') | |
| @data << processed unless processed.nil? || processed == "" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment