lib/verse/sanitizer.rb in verse-0.3.0 vs lib/verse/sanitizer.rb in verse-0.4.0
- old
+ new
@@ -15,9 +15,21 @@
# @api public
def sanitize(text)
text.gsub(ANSI_MATCHER, '')
end
+ # Check if string is an ANSI code
+ #
+ # @param [String] string
+ # the string to check
+ #
+ # @return [Boolean]
+ #
+ # @api public
+ def ansi?(string)
+ !!(string =~ /^(\[)?\033(\[)?[;?\d]*[\dA-Za-z]([\];])?$/)
+ end
+
# Replace separator with whitespace
#
# @example
# replace(" \n ") # => " "
# replace("\n") # => " "