Class ANSI::String
In: lib/ansi/string.rb
Parent: Object

IMPORTANT! ANSI::String is experimental!!!

ANSI::String stores a regular string (`@text`) and an associative array that ties a character index to an ANSI code (`marks`). For example is we have the string:

  "Big Apple"

And applied the color red to it, the marks list would be:

  [[0, :red], [9, :clear]]

TODO: In the future we may be able to subclass String, instead of delegating via @text, but not until it is more compatible.

Methods

+   []   ansi   ansi!   black   black!   blue   blue!   bold   bold!   color   color!   cyan   cyan!   downcase   downcase!   green   green!   gsub   gsub!   magenta   magenta!   new   red   red!   size   slice   sub   sub!   to_s   to_str   underline   underline!   upcase   upcase!   yellow   yellow!  

Constants

CLR = ANSI::Code::CLEAR

Attributes

marks  [R] 
text  [R] 

Public Class methods

Public Instance methods

Add one String to another, or to a regular String.

[](*args)

Alias for slice

color(code)

Alias for ansi

color!(code)

Alias for ansi!

Downcase the string.

The size of the base text.

This is more limited than the normal String method. It does not yet support a block, and replacement won‘t substitue for \1, \2, etc.

TODO: block support.

Convert Ansi::String object to normal String. This converts the intental markup codes to ANSI codes.

to_str()

Alias for to_s

Upcase the string.

[Validate]