class TTY::Prompt::Statement
A class representing a statement output to prompt.
Attributes
color[R]
Color used to display statement
@api public
newline[R]
Flag to display newline
@api public
Public Class Methods
new(prompt, newline: true, color: false)
click to toggle source
Initialize a Statement
@param [TTY::Prompt] prompt
@param [Hash] options
@option options [Symbol] :newline
force a newline break after the message
@option options [Symbol] :color
change the message display to color
@api public
# File lib/tty/prompt/statement.rb, line 30 def initialize(prompt, newline: true, color: false) @prompt = prompt @newline = newline @color = color end
Public Instance Methods
call(message)
click to toggle source
Output the message to the prompt
@param [String] message
the message to be printed to stdout
@api public
# File lib/tty/prompt/statement.rb, line 42 def call(message) message = @prompt.decorate(message, *color) if color if newline && /( |\t)(\e\[\d+(;\d+)*m)?\Z/ !~ message @prompt.puts message else @prompt.print message @prompt.flush end end