Sha256: 7abe63f9b5cbd5dcb39008c44e873d58270e4c60bf25d5fd8fa1b5973cd8032d
Contents?: true
Size: 685 Bytes
Versions: 5
Compression:
Stored size: 685 Bytes
Contents
# -*- encoding: utf-8 -*- module Ackr # Format strings to be displayed on terminal. class Formatter # Public: # # search_term - The String or Regexp to look for. def initialize search_term @search_term = search_term end # Public: format a line with matched term(s). # # line - The String line to be displayed. # num - The Integer number of the line (in base 1). # # Returns a formatted String. def line line, num begin line.strip! rescue Exception => ex puts "Error ".background(:red) + ex.message end "#{'%4i' % num}| #{Colorizer::for_line(line, @search_term)}" end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
ackr-0.3.0 | lib/ackr/formatter.rb |
ackr-0.2.4 | lib/ackr/formatter.rb |
ackr-0.2.3 | lib/ackr/formatter.rb |
ackr-0.2.2 | lib/ackr/formatter.rb |
ackr-0.2 | lib/ackr/formatter.rb |