Class: TTY::Prompt::Statement
- Inherits:
-
Object
- Object
- TTY::Prompt::Statement
- Defined in:
- lib/tty/prompt/statement.rb
Overview
A class representing a statement output to prompt.
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Color used to display statement.
-
#newline ⇒ Object
readonly
Flag to display newline.
Instance Method Summary collapse
-
#call(message) ⇒ Object
Output the message to the prompt.
-
#initialize(prompt, newline: true, color: false) ⇒ Statement
constructor
Initialize a Statement.
Constructor Details
#initialize(prompt, newline: true, color: false) ⇒ Statement
Initialize a Statement
31 32 33 34 35 |
# File 'lib/tty/prompt/statement.rb', line 31 def initialize(prompt, newline: true, color: false) @prompt = prompt @newline = newline @color = color end |
Instance Attribute Details
#color ⇒ Object (readonly)
Color used to display statement
16 17 18 |
# File 'lib/tty/prompt/statement.rb', line 16 def color @color end |
#newline ⇒ Object (readonly)
Flag to display newline
11 12 13 |
# File 'lib/tty/prompt/statement.rb', line 11 def newline @newline end |
Instance Method Details
#call(message) ⇒ Object
Output the message to the prompt
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/tty/prompt/statement.rb', line 43 def call() = @prompt.decorate(, *color) if color if newline && /( |\t)(\e\[\d+(;\d+)*m)?\Z/ !~ @prompt.puts else @prompt.print @prompt.flush end end |