Sha256: 935ed52fa193a640ba5844c7a4e93fa1399879546af34da1be7018f8e709c2da
Contents?: true
Size: 665 Bytes
Versions: 3
Compression:
Stored size: 665 Bytes
Contents
module Rambling module Trie module Readers # File reader for .txt files. class PlainText # 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 end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rambling-trie-1.0.2 | lib/rambling/trie/readers/plain_text.rb |
rambling-trie-1.0.1 | lib/rambling/trie/readers/plain_text.rb |
rambling-trie-1.0.0 | lib/rambling/trie/readers/plain_text.rb |