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
NONE_FOUND_COLOR =
:green

Class Method Summary collapse

Class Method Details

.cheat_rows(cheats, search_term, colorize) ⇒ Object



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

def self.cheat_rows(cheats, search_term, colorize)
  cheats.map do |cheat|
    description = cheat[:description]
    command = cheat[:command]
    print description, DESCRIPTION_COLOR, colorize
    print command, COMMAND_COLOR, colorize
    puts
  end
  print "None found", NONE_FOUND_COLOR, colorize if cheats.size == 0
end


21
22
23
24
# File 'lib/grepg/formatter.rb', line 21

def self.print(text, color, colorize)
  text = text.colorize(color) if colorize
  puts text
end