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.
51 52 53 |
# File 'lib/pve/helper.rb', line 51 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.
49 50 51 |
# File 'lib/pve/helper.rb', line 49 def color_codes @color_codes end |
#string ⇒ Object (readonly)
Returns the value of attribute string.
49 50 51 |
# File 'lib/pve/helper.rb', line 49 def string @string end |
Instance Method Details
#<=>(o) ⇒ Object
67 |
# File 'lib/pve/helper.rb', line 67 def <=>(o) @string <=> o.string end |
#inspect ⇒ Object
55 56 57 |
# File 'lib/pve/helper.rb', line 55 def inspect "#<ColoredString #{@color_codes} #{@string.inspect}>" end |
#length ⇒ Object Also known as: size
59 |
# File 'lib/pve/helper.rb', line 59 def length() @string.length end |
#to_s ⇒ Object Also known as: to_str
def to_str() self end
62 |
# File 'lib/pve/helper.rb', line 62 def to_s() "\e[#{@color_codes}m#{@string}\e[0m" end |