Class: Rambling::Trie::Readers::PlainText

Inherits:
Reader
  • Object
show all
Defined in:
lib/rambling/trie/readers/plain_text.rb

Overview

File reader for ‘.txt` files.

Instance Method Summary collapse

Instance Method Details

#each_word(filepath) {|String| ... } ⇒ self

Yields each word read from a ‘.txt` file.

Parameters:

  • filepath (String)

    the full path of the file to load the words from.

Yields:

  • (String)

    Each line read from the file.

Returns:

  • (self)


12
13
14
15
16
17
18
# File 'lib/rambling/trie/readers/plain_text.rb', line 12

def each_word filepath
  return enum_for :each_word, filepath unless block_given?

  ::File.foreach(filepath) { |line| yield line.chomp! }

  self
end