Module: WordsCounted
- Defined in:
- lib/words_counted.rb,
lib/words_counted/counter.rb,
lib/words_counted/version.rb,
lib/words_counted/tokeniser.rb,
lib/words_counted/deprecated.rb
Defined Under Namespace
Modules: Deprecated Classes: Counter, Tokeniser
Constant Summary collapse
- VERSION =
"1.0.3"
Class Method Summary collapse
-
.count(input, options = {}) ⇒ WordsCounted::Counter
Takes a string, tokenises it, and returns an instance of Counter with the resulting tokens.
-
.from_file(path, options = {}) ⇒ WordsCounted::Counter
Takes a file path, reads the file and tokenises its contents, and returns an instance of Counter with the resulting tokens.
Class Method Details
.count(input, options = {}) ⇒ WordsCounted::Counter
Takes a string, tokenises it, and returns an instance of Counter with the resulting tokens.
25 26 27 28 |
# File 'lib/words_counted.rb', line 25 def self.count(input, = {}) tokens = Tokeniser.new(input).tokenise(**) Counter.new(tokens) end |
.from_file(path, options = {}) ⇒ WordsCounted::Counter
Takes a file path, reads the file and tokenises its contents, and returns an instance of Counter with the resulting tokens.
39 40 41 42 43 44 |
# File 'lib/words_counted.rb', line 39 def self.from_file(path, = {}) tokens = File.open(path) do |file| Tokeniser.new(file.read).tokenise(**) end Counter.new(tokens) end |