lib/grepg/formatter.rb in grepg-0.0.3 vs lib/grepg/formatter.rb in grepg-0.0.4

- old
+ new

@@ -1,13 +1,21 @@ require 'colorize' module GrepPage class Formatter # Displays an array of cheats # TODO: Highlight search term - def self.cheat_rows(cheats, search_term) + DESCRIPTION_COLOR= :green + COMMAND_COLOR= :blue + def self.cheat_rows(cheats, search_term, colorize) cheats.map do |cheat| - puts cheat[:description].colorize(:green) - puts cheat[:command].colorize(:blue) + description = cheat[:description] + command = cheat[:command] + if colorize + description = description.colorize(DESCRIPTION_COLOR) + command = command.colorize(COMMAND_COLOR) + end + puts description + puts command puts end end end end