Object
Creates a new Builder object with the given arguments, opens the word-list file, passes the builder object to the given block then finally closes the word-list file.
Builder.build('some/path') do |builder|
builder.parse(readline)
end
# File lib/wordlist/builder.rb, line 39 def self.build(*arguments,&block) self.new(*arguments) do |builder| builder.open! builder.build!(&block) builder.close! end end
Add the specified words to the word-list.
# File lib/wordlist/builder.rb, line 90 def +(words) words.each { |word| self << word } return self end
Appends the specified word to the word-list file, only if it has not been previously seen.
# File lib/wordlist/builder.rb, line 77 def <<(word) if @file @filter.pass(word) do |unique| @file.puts unique end end return self end
Default to be called when the word-list is to be built, simply calls the given block.
# File lib/wordlist/builder.rb, line 69 def build!(&block) block.call(self) if block end
Closes the word-list file.
# File lib/wordlist/builder.rb, line 118 def close! if @file @file.close @file = nil @filter = nil end end
Opens the word-list file for writing. If the file already exists, the previous words will be used to filter future duplicate words.
# File lib/wordlist/builder.rb, line 51 def open! @filter = UniqueFilter.new if File.file?(@path) File.open(@path) do |file| file.each_line do |line| @filter.saw!(line.chomp) end end end @file = File.new(@path,File::RDWR | File::CREAT | File::APPEND) end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.