Class: Bcome::LoadingBar::Indicator::Progress

Inherits:
Base
  • Object
show all
Defined in:
lib/objects/loading_bar/indicator/progress.rb

Constant Summary

Constants inherited from Base

Base::CHARACTERS, Base::SIGNAL_FAILURE, Base::SIGNAL_STOP, Base::SIGNAL_SUCCESS

Instance Method Summary collapse

Methods inherited from Base

#indicate, #initialize

Constructor Details

This class inherits a constructor from Bcome::LoadingBar::Indicator::Base

Instance Method Details

#increment_failureObject



19
20
21
22
# File 'lib/objects/loading_bar/indicator/progress.rb', line 19

def increment_failure
  @results << 0
  @progression += progressed_glyph.bc_red.bold
end

#increment_successObject



14
15
16
17
# File 'lib/objects/loading_bar/indicator/progress.rb', line 14

def increment_success
  @results << 1
  @progression += progressed_glyph.bc_green.bold
end

#showObject



7
8
9
10
11
12
# File 'lib/objects/loading_bar/indicator/progress.rb', line 7

def show
  line = ''
  @results.map { |r| line += (r == 1 ? progressed_glyph.to_s.bc_green.bold : progressed_glyph.to_s.bc_red.bold) }
  line += glyph.bc_orange.to_s * (@progress_size - @results.size)
  print "\r#{@title}\s#{line}\s(#{@results.size}/#{@progress_size})\s"
end