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)
Constructor Details
#initialize(string, color_codes) ⇒ ColoredString
Returns a new instance of ColoredString.
79 80 81 |
# File 'lib/pve/helper.rb', line 79 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.
77 78 79 |
# File 'lib/pve/helper.rb', line 77 def color_codes @color_codes end |
#string ⇒ Object (readonly)
Returns the value of attribute string.
77 78 79 |
# File 'lib/pve/helper.rb', line 77 def string @string end |
Instance Method Details
#<=>(o) ⇒ Object
93 |
# File 'lib/pve/helper.rb', line 93 def <=>(o) @string <=> o.string end |
#inspect ⇒ Object
83 84 85 |
# File 'lib/pve/helper.rb', line 83 def inspect "#<ColoredString #{@color_codes} #{@string.inspect}>" end |
#length ⇒ Object Also known as: size
87 |
# File 'lib/pve/helper.rb', line 87 def length() @string.length end |
#to_s ⇒ Object Also known as: to_str
89 |
# File 'lib/pve/helper.rb', line 89 def to_s() "\e[#{@color_codes}m#{@string}\e[0m" end |