Class: TTY::Shell::Statement
- Inherits:
-
Object
- Object
- TTY::Shell::Statement
- Defined in:
- lib/tty/shell/statement.rb
Overview
A class representing a statement output to shell.
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Color used to display statement.
-
#newline ⇒ Object
readonly
Flag to display newline.
Instance Method Summary collapse
-
#declare(message) ⇒ Object
Output the message to the shell.
-
#initialize(shell = Shell.new, options = {}) ⇒ Statement
constructor
Initialize a Statement.
Constructor Details
#initialize(shell = Shell.new, options = {}) ⇒ Statement
Initialize a Statement
35 36 37 38 39 40 |
# File 'lib/tty/shell/statement.rb', line 35 def initialize(shell = Shell.new, = {}) @shell = shell @pastel = Pastel.new @newline = .fetch(:newline, true) @color = .fetch(:color, false) end |
Instance Attribute Details
#color ⇒ Object (readonly)
Color used to display statement
20 21 22 |
# File 'lib/tty/shell/statement.rb', line 20 def color @color end |
#newline ⇒ Object (readonly)
Flag to display newline
15 16 17 |
# File 'lib/tty/shell/statement.rb', line 15 def newline @newline end |
Instance Method Details
#declare(message) ⇒ Object
Output the message to the shell
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/tty/shell/statement.rb', line 48 def declare() = @pastel.decorate , *color if color if newline && /( |\t)(\e\[\d+(;\d+)*m)?\Z/ !~ shell.output.puts else shell.output.print shell.output.flush end end |