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

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

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.

  • (String)

Yields:

  • (String)

    Each line read from the file.

Yield Parameters:

  • arg0 (String)

Yield Returns:

  • (void)

Returns:

  • (self)


12
13
14
15
16
17
18
19
20
21
# 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) do |line|
    line.chomp!
    yield line
  end

  self
end