Sha256: 8682c54ba3d75591b8e32b94a823b4e7a3568c754444c972705248faa4c4e9f1

Contents?: true

Size: 670 Bytes

Versions: 1

Compression:

Stored size: 670 Bytes

Contents

require 'wordlist/list'

module Wordlist
  class FlatFile < List

    # The path to the flat-file
    attr_accessor :path

    #
    # Creates a new FlatFile list with the specified _path_ and given
    # _options_.
    #
    def initialize(path,options={},&block)
      @path = path

      super(options,&block)
    end

    #
    # Enumerates through every word in the flat-file, passing each
    # word to the given _block_.
    #
    #   flat_file.each_word do |word|
    #     puts word
    #   end
    #
    def each_word(&block)
      File.open(@path) do |file|
        file.each_line do |line|
          yield line.chomp
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wordlist-0.1.0 lib/wordlist/flat_file.rb