class TableView

Constants

CHECKMARK_CHARS_OFFSET
COUNT_CHARS_OFFSET

Public Class Methods

new(map) click to toggle source
# File lib/views.rb, line 49
def initialize(map)
  @map = map
end

Public Instance Methods

to_s() click to toggle source
# File lib/views.rb, line 55
def to_s
  @map.map do |(key, count)|
    color = count > 0 ? GREEN : RED
    done = count > 0 ? "✓" : " "
    description = key.at_width(SCREEN_WIDTH - COUNT_CHARS_OFFSET - CHECKMARK_CHARS_OFFSET)
    [color, done, ' ', description, count.to_s.rjust(COUNT_CHARS_OFFSET), RESET].join
  end
end