Class: MiniReadline::Prompt
- Inherits:
-
Object
- Object
- MiniReadline::Prompt
- Defined in:
- lib/mini_readline/read_line/prompt.rb
Overview
A class used to hold prompt strings that may contain ANSI terminal control embellishments.
Instance Attribute Summary collapse
-
#length ⇒ Object
readonly
Get the length without ANSI sequences.
-
#text ⇒ Object
readonly
Get the text.
Instance Method Summary collapse
-
#initialize(text) ⇒ Prompt
constructor
Create a special prompt text.
-
#inspect ⇒ Object
Inspect the prompt.
Constructor Details
#initialize(text) ⇒ Prompt
Create a special prompt text.
17 18 19 20 |
# File 'lib/mini_readline/read_line/prompt.rb', line 17 def initialize(text) @text = text @length = text.gsub(/\x1B\[(\d|;)*[@-~]/, "").length end |
Instance Attribute Details
#length ⇒ Object (readonly)
Get the length without ANSI sequences.
14 15 16 |
# File 'lib/mini_readline/read_line/prompt.rb', line 14 def length @length end |
#text ⇒ Object (readonly)
Get the text.
11 12 13 |
# File 'lib/mini_readline/read_line/prompt.rb', line 11 def text @text end |
Instance Method Details
#inspect ⇒ Object
Inspect the prompt
23 24 25 |
# File 'lib/mini_readline/read_line/prompt.rb', line 23 def inspect "<Prompt: #{@text.inspect}>" end |