Sha256: 66105f07faa45cca8769e62e64e5c295ba0df445278e2b051079131a5a3a82b0

Contents?: true

Size: 697 Bytes

Versions: 4

Compression:

Stored size: 697 Bytes

Contents

require 'colorize'
module GrepPage
  class Formatter
    # Displays an array of cheats
    # TODO: Highlight search term
    DESCRIPTION_COLOR = :green
    COMMAND_COLOR = :blue
    NONE_FOUND_COLOR = :green

    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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grepg-0.0.9 lib/grepg/formatter.rb
grepg-0.0.8 lib/grepg/formatter.rb
grepg-0.0.7 lib/grepg/formatter.rb
grepg-0.0.6 lib/grepg/formatter.rb