Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/ruby_rich/panel.rb
Overview
Extend String to remove ANSI codes for alignment
Instance Method Summary collapse
Instance Method Details
#display_width ⇒ Object
200 201 202 203 204 205 206 |
# File 'lib/ruby_rich/panel.rb', line 200 def display_width width = 0 self.uncolorize.each_char do |char| width += Unicode::DisplayWidth.of(char) end width end |
#uncolorize ⇒ Object
196 197 198 |
# File 'lib/ruby_rich/panel.rb', line 196 def uncolorize gsub(/\e\[[0-9;]*m/, '') end |