Class: MatchData
- Inherits:
-
Object
- Object
- MatchData
- Defined in:
- lib/matchdata-highlight.rb
Instance Method Summary collapse
Instance Method Details
#_highlight(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/matchdata-highlight.rb', line 12 def _highlight( = {}) = { :begin => Term::ANSIColor.red, :end => Term::ANSIColor.clear, }.merge() marker_begin = [:begin] marker_end = [:end] buf = string.dup buf[self.begin(0), 0] = marker_begin buf[self.end(0) + marker_begin.size, 0] = marker_end buf end |
#highlight(*args) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/matchdata-highlight.rb', line 4 def highlight(*args) if args.empty? or args.first.kind_of?(Hash) _highlight(*args) else _highlight(:begin => args[0], :end => args[1]) end end |