Class: Fretboard::Console
- Inherits:
-
Object
- Object
- Fretboard::Console
- Defined in:
- lib/fretboard/console.rb
Class Method Summary collapse
-
.danger(text) ⇒ Object
def self.warning(text) new(text, :yellow).print end.
- .log(text) ⇒ Object
- .print_table(headings, rows) ⇒ Object
Instance Method Summary collapse
-
#initialize(text, color = nil) ⇒ Console
constructor
A new instance of Console.
- #print ⇒ Object
Constructor Details
#initialize(text, color = nil) ⇒ Console
Returns a new instance of Console.
32 33 34 35 |
# File 'lib/fretboard/console.rb', line 32 def initialize(text, color = nil) @text = text @color = color end |
Class Method Details
.danger(text) ⇒ Object
def self.warning(text)
new(text, :yellow).print
end
18 19 20 |
# File 'lib/fretboard/console.rb', line 18 def self.danger(text) new(text, :red).print end |
.log(text) ⇒ Object
6 7 8 |
# File 'lib/fretboard/console.rb', line 6 def self.log(text) new(text, nil).print end |
.print_table(headings, rows) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/fretboard/console.rb', line 22 def self.print_table(headings, rows) table = Terminal::Table.new( headings: headings, rows: rows, style: { border_x: '~', border_i: '~' } ) new(table.to_s, nil).print end |
Instance Method Details
#print ⇒ Object
37 38 39 |
# File 'lib/fretboard/console.rb', line 37 def print puts @text.colorize(@color) end |