Sha256: a459a0ddaf6b799f6ceeebfebb49ebde0ae3d941813ce939ffb03251fdb26e46
Contents?: true
Size: 600 Bytes
Versions: 4
Compression:
Stored size: 600 Bytes
Contents
module Rambling module Trie # File reader for .txt files class PlainTextReader # Yields each word read from a .txt file # @param [String] filepath the full path of the file to load the words from. # @yield [String] Each line read from the file. def each_word(filepath) each_line(filepath) { |line| yield line.chomp } end private def each_line(filepath) open(filepath) { |file| file.each_line { |line| yield line } } end def open(filepath) File.open(filepath) { |file| yield file } end end end end
Version data entries
4 entries across 4 versions & 1 rubygems