Class: HTTPDisk::Grep::HeaderPrinter
- Defined in:
- lib/httpdisk/grep/printer.rb
Overview
header, then each match
Constant Summary
Constants inherited from Printer
Instance Attribute Summary collapse
-
#head ⇒ Object
readonly
Returns the value of attribute head.
-
#printed ⇒ Object
readonly
Returns the value of attribute printed.
Attributes inherited from Printer
Instance Method Summary collapse
-
#initialize(output, head) ⇒ HeaderPrinter
constructor
A new instance of HeaderPrinter.
- #print(path, payload, all_matches) ⇒ Object
Constructor Details
#initialize(output, head) ⇒ HeaderPrinter
Returns a new instance of HeaderPrinter.
61 62 63 64 65 |
# File 'lib/httpdisk/grep/printer.rb', line 61 def initialize(output, head) super(output) @head = head @printed = 0 end |
Instance Attribute Details
#head ⇒ Object (readonly)
Returns the value of attribute head.
59 60 61 |
# File 'lib/httpdisk/grep/printer.rb', line 59 def head @head end |
#printed ⇒ Object (readonly)
Returns the value of attribute printed.
59 60 61 |
# File 'lib/httpdisk/grep/printer.rb', line 59 def printed @printed end |
Instance Method Details
#print(path, payload, all_matches) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/httpdisk/grep/printer.rb', line 67 def print(path, payload, all_matches) # separator & filename output.puts if (@printed += 1) > 1 output.puts path # --head if head io = StringIO.new payload.write_header(io) io.string.lines.each { output.puts "< #{_1}" } end # matches all_matches.each { print_matches(_1) } end |