Created
March 25, 2016 06:15
-
-
Save SuperManEver/df81df81932341e7b19e to your computer and use it in GitHub Desktop.
Display class responsible for displaying search results
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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