Class: TableView
Constant Summary
Constants included from TerminalUtils
TerminalUtils::ERASE_DISPLAY, TerminalUtils::GREEN, TerminalUtils::RED, TerminalUtils::RESET, TerminalUtils::RESTORE_CURSOR, TerminalUtils::SAVE_CURSOR, TerminalUtils::SCREEN_WIDTH
Instance Method Summary collapse
-
#initialize(map) ⇒ TableView
constructor
A new instance of TableView.
- #to_s ⇒ Object
Constructor Details
#initialize(map) ⇒ TableView
Returns a new instance of TableView.
49 50 51 |
# File 'lib/views.rb', line 49 def initialize(map) @map = map end |
Instance Method Details
#to_s ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/views.rb', line 53 def to_s @map.map do |(key, count)| color = count > 0 ? GREEN : RED done = count > 0 ? "✓" : " " description = key.truncate(SCREEN_WIDTH - 4).ljust(SCREEN_WIDTH - 3) [color, done, ' ', description, count.to_s, RESET].join end end |