class ProgressBarView

Constants

EXTRA_CHARS_OFFSET
USABLE_WIDTH

Public Class Methods

new(percent) click to toggle source
# File lib/views.rb, line 35
def initialize(percent)
  @percent = Float([percent, 100.0].min)
end

Public Instance Methods

to_s() click to toggle source
# File lib/views.rb, line 39
def to_s
  complete = '#' * ((@percent / 100.0) * USABLE_WIDTH).to_i
  incomplete = ' ' * (USABLE_WIDTH - complete.length)
  [GREEN, ' [', complete, incomplete, ']', (@percent.to_i.to_s + '%').rjust(5), RESET].join
end