Class: PTJ::Parser::CountPassOnly
- Inherits:
-
FileParser
- Object
- FileParser
- PTJ::Parser::CountPassOnly
- Defined in:
- lib/ptj/parser/fileparser/countpassonly.rb
Overview
FileParser class which allows you to parse a file line by line.
Instance Method Summary collapse
-
#parse_line(line) ⇒ Object
Expecting the following format: pass, hash pass, hash pass, hash.
-
#total_count(file) ⇒ Object
Method used to return the total number of passwords that will be added to PTJ.
Instance Method Details
#parse_line(line) ⇒ Object
Expecting the following format: pass, hash pass, hash pass, hash
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ptj/parser/fileparser/countpassonly.rb', line 16 def parse_line(line) if line =~ /^\s*(\d+)\s*(\S+)\s*$/ count = $~[1] pass = $~[2] hash = nil end ret_ary = [] count.to_i.times do ret_ary << {:mypass => pass, :myhash => hash} end ret_ary end |
#total_count(file) ⇒ Object
Method used to return the total number of passwords that will be added to PTJ
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ptj/parser/fileparser/countpassonly.rb', line 37 def total_count(file) file_obj = File.new(file,'r') counter = 0 while (line = file_obj.gets) line = line.force_encoding("BINARY") if line =~ /^\s*(\d+)\s*(\S+)\s*$/ counter += $~[1].to_i end end counter end |