Class: ColoredString
Instance Attribute Summary collapse
-
#color_codes ⇒ Object
readonly
Returns the value of attribute color_codes.
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Instance Method Summary collapse
- #<=>(o) ⇒ Object
-
#initialize(string, color_codes) ⇒ ColoredString
constructor
A new instance of ColoredString.
- #inspect ⇒ Object
- #length ⇒ Object (also: #size)
-
#to_s ⇒ Object
(also: #to_str)
def to_str() self end.
Constructor Details
#initialize(string, color_codes) ⇒ ColoredString
Returns a new instance of ColoredString.
65 66 67 |
# File 'lib/pve/helper.rb', line 65 def initialize string, color_codes @string, @color_codes = string, color_codes end |
Instance Attribute Details
#color_codes ⇒ Object (readonly)
Returns the value of attribute color_codes.
63 64 65 |
# File 'lib/pve/helper.rb', line 63 def color_codes @color_codes end |
#string ⇒ Object (readonly)
Returns the value of attribute string.
63 64 65 |
# File 'lib/pve/helper.rb', line 63 def string @string end |
Instance Method Details
#<=>(o) ⇒ Object
81 |
# File 'lib/pve/helper.rb', line 81 def <=>(o) @string <=> o.string end |
#inspect ⇒ Object
69 70 71 |
# File 'lib/pve/helper.rb', line 69 def inspect "#<ColoredString #{@color_codes} #{@string.inspect}>" end |
#length ⇒ Object Also known as: size
73 |
# File 'lib/pve/helper.rb', line 73 def length() @string.length end |
#to_s ⇒ Object Also known as: to_str
def to_str() self end
76 |
# File 'lib/pve/helper.rb', line 76 def to_s() "\e[#{@color_codes}m#{@string}\e[0m" end |