Method: Wordlist::File#initialize

Defined in:
lib/wordlist/file.rb

#initialize(path, format: Format.infer(path)) ⇒ File

Opens a wordlist file.

Parameters:

  • path (String)

    The path to the .txt file wordlist read from.

  • format (:txt, :gz, :bzip2, :xz, nil) (defaults to: Format.infer(path))

    The format of the wordlist. If not given the format will be inferred from the file extension.

Raises:

Since:

  • 1.0.0



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/wordlist/file.rb', line 48

def initialize(path, format: Format.infer(path))
  @path   = ::File.expand_path(path)
  @format = format

  unless ::File.file?(@path)
    raise(WordlistNotFound,"wordlist file does not exist: #{@path.inspect}")
  end

  unless Format::FORMATS.include?(@format)
    raise(UnknownFormat,"unknown format given: #{@format.inspect}")
  end
end