Sha256: 86df41a445244c2e210874c32b6e30f29b7f28c96e97ef03b718849be864fa33

Contents?: true

Size: 586 Bytes

Versions: 1

Compression:

Stored size: 586 Bytes

Contents

# frozen_string_literal: true

module Rambling
  module Trie
    module Readers
      # File reader for +.txt+ files.
      class PlainText < Reader
        # 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.
        # @return [self]
        def each_word filepath
          return enum_for :each_word, filepath unless block_given?

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

          self
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rambling-trie-2.5.0 lib/rambling/trie/readers/plain_text.rb