Module: WordFinder
- Defined in:
- lib/word_finder/node.rb,
lib/word_finder.rb,
lib/word_finder/checker.rb,
lib/word_finder/version.rb
Overview
WordFinder. Copyright © 2012 Chris Corbyn.
See LICENSE file for details.
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.0.2"
Class Method Summary collapse
-
.words_in(phrase, options = {}) ⇒ Array<String>
Find all the words in the given phrase, ignoring unrecognized characters.
Class Method Details
.words_in(phrase, options = {}) ⇒ Array<String>
Find all the words in the given phrase, ignoring unrecognized characters.
Words will be accumulated to use the longest possible matches.
26 27 28 29 30 |
# File 'lib/word_finder.rb', line 26 def words_in(phrase, = {}) Node.new().tap{|node| phrase.each_char(&node.method(:insert)) }.words.reject{|m| m !~ /\w/} end |