Skip to content

Instantly share code, notes, and snippets.

@SuperManEver
Created March 25, 2016 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SuperManEver/df81df81932341e7b19e to your computer and use it in GitHub Desktop.
Save SuperManEver/df81df81932341e7b19e to your computer and use it in GitHub Desktop.
Display class responsible for displaying search results
require 'paint'
class Display
def self.display(args)
# display search results
@@search_result = args[:result]
@@options = args[:options]
@@search_result.each_pair do |file_name, lines|
display_search_result(file_name, lines)
end
end
def self.display_search_result(file_name, lines)
unless lines.empty?
puts Paint[file_name, :red, :bold] if @@options[:colour]
puts file_name if @@options[:no_colour]
lines.each do |line|
puts "#{Paint[line.first, :blue, :bright]} #{line[1..-1].join("\n")}" if @@options[:colour]
puts "#{line.first} #{line[1..-1].join("\n")}" if @@options[:no_colour]
end
puts
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment