Class: MatchData
- Inherits:
-
Object
- Object
- MatchData
- Includes:
- Term::ANSIColor
- Defined in:
- lib/pretty_match_data.rb
Instance Method Summary collapse
Instance Method Details
#_next_color ⇒ Object
13 14 15 16 17 |
# File 'lib/pretty_match_data.rb', line 13 def _next_color @_color ||= %w(red green yellow blue magenta cyan).map { |c| "on_#{c}".to_sym } @_color.push @_color.shift @_color[0] end |
#to_s ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/pretty_match_data.rb', line 5 def to_s match = self[0].dup to_a[1..-1].each do |capture| match.gsub!(capture) { |s| underline + send(_next_color) { s } + underline } end pre_match + underline { match } + post_match end |