Sha256: 892d3889cae1df2abbed6b5f620d22c55912ec01500c1951770504fa0c2af082
Contents?: true
Size: 794 Bytes
Versions: 1
Compression:
Stored size: 794 Bytes
Contents
# -*- encoding: utf-8 -*- require 'rainbow' module Ackr # Methods to add terminal color commands into strings. module Colorizer # Public: Highlight a filename. # # string - The filename. # # Returns the String filename highlighted. def self.for_file string string.foreground(:blue).bright.underline end # Public: Highlight a matched file line. # # string - The line. # search - The String search term. # # Returns the String line highlighted. def self.for_line string, search search = Regexp.new(search, Regexp::IGNORECASE) if search.is_a?(String) begin string.gsub(search) {|exp| exp.bright } rescue Exception => ex puts "Error ".background(:red) + ex.message end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ackr-0.2 | lib/ackr/colorizer.rb |