Class: Msf::Ui::Console::TablePrint::HighlightSubstringStyler
- Inherits:
-
Object
- Object
- Msf::Ui::Console::TablePrint::HighlightSubstringStyler
- Defined in:
- lib/msf/ui/console/table_print/highlight_substring_styler.rb
Constant Summary collapse
- HIGHLIGHT_COLOR =
'%bgmag'
- RESET_COLOR =
'%clr'
Instance Method Summary collapse
-
#initialize(terms) ⇒ HighlightSubstringStyler
constructor
A new instance of HighlightSubstringStyler.
- #style(value) ⇒ Object
Constructor Details
#initialize(terms) ⇒ HighlightSubstringStyler
Returns a new instance of HighlightSubstringStyler.
12 13 14 |
# File 'lib/msf/ui/console/table_print/highlight_substring_styler.rb', line 12 def initialize(terms) @highlight_terms = /#{Regexp.union(terms.compact).source}/i end |
Instance Method Details
#style(value) ⇒ Object
16 17 18 |
# File 'lib/msf/ui/console/table_print/highlight_substring_styler.rb', line 16 def style(value) value.gsub(@highlight_terms) { |match| "#{HIGHLIGHT_COLOR}#{match}#{RESET_COLOR}" } end |