Class: GrepPage::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/grepg/formatter.rb

Constant Summary collapse

DESCRIPTION_COLOR =

Displays an array of cheats TODO: Highlight search term

:green
COMMAND_COLOR =
:blue

Class Method Summary collapse

Class Method Details

.cheat_rows(cheats, search_term, colorize) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/grepg/formatter.rb', line 8

def self.cheat_rows(cheats, search_term, colorize)
  cheats.map do |cheat|
    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