Method: Doing::StringHighlight#last_color

Defined in:
lib/doing/string/highlight.rb

#last_colorString

Returns the last escape sequence from a string.

Actually returns all escape codes, with the assumption that the result of inserting them will generate the same color as was set at the end of the string. Because you can send modifiers like dark and bold separate from color codes, only using the last code may not render the same style.

Returns:

  • (String)

    All escape codes in string



73
74
75
# File 'lib/doing/string/highlight.rb', line 73

def last_color
  scan(/\e\[[\d;]+m/).join('')
end