class HTTPDisk::Grep::Printer
Constants
- GREP_COLOR
Attributes
output[R]
Public Class Methods
new(output)
click to toggle source
# File lib/httpdisk/grep/printer.rb, line 8 def initialize(output) @output = output end
Public Instance Methods
print(path, payload, all_matches)
click to toggle source
# File lib/httpdisk/grep/printer.rb, line 12 def print(path, payload, all_matches); end
Protected Instance Methods
grep_color()
click to toggle source
helpers for subclasses
# File lib/httpdisk/grep/printer.rb, line 20 def grep_color @grep_color ||= (ENV['GREP_COLOR'] || GREP_COLOR) end
print_matches(matches)
click to toggle source
# File lib/httpdisk/grep/printer.rb, line 24 def print_matches(matches) s = matches.first.string if output.tty? s = [].tap do |result| ii = 0 matches.each do result << s[ii..._1.begin(0)] result << "\e[" result << grep_color result << 'm' result << _1[0] result << "\e[0m" ii = _1.end(0) end result << s[ii..] end.join end output.puts s end