class ANSI::Chain
ANSI::Chain was inspired by Kazuyoshi Tlacaelel's Isna library.
Attributes
codes[R]
string[R]
Public Class Methods
new(string)
click to toggle source
# File lib/ansi/chain.rb, line 10 def initialize(string) @string = string.to_s @codes = [] end
Public Instance Methods
method_missing(s, *a, &b)
click to toggle source
Calls superclass method
# File lib/ansi/chain.rb, line 22 def method_missing(s, *a, &b) if ANSI::CHART.key?(s) @codes << s self else super(s, *a, &b) end end
to_s()
click to toggle source
# File lib/ansi/chain.rb, line 32 def to_s if codes.empty? result = @string else result = Code.ansi(@string, *codes) codes.clear end result end
to_str()
click to toggle source
# File lib/ansi/chain.rb, line 43 def to_str to_s end