Class: Bcome::LoadingBar::Indicator::Base

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

Direct Known Subclasses

Basic, Progress

Constant Summary collapse

CHARACTERS =
%w[       ].freeze
SIGNAL_SUCCESS =
'USR1'
SIGNAL_FAILURE =
'USR2'
SIGNAL_STOP =
'SIGKILL'

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Base

Returns a new instance of Base.



13
14
15
16
17
18
19
20
21
# File 'lib/objects/loading_bar/indicator/base.rb', line 13

def initialize(config = {})
  @progress_size = config[:size]
  @title = config[:title]
  @completed_title = config[:completed_title]

  @current_character = 0
  @progression = ''
  @results = []
end

Instance Method Details

#increment_failureObject



40
41
42
# File 'lib/objects/loading_bar/indicator/base.rb', line 40

def increment_failure
  raise 'Should be overidden'
end

#increment_successObject



36
37
38
# File 'lib/objects/loading_bar/indicator/base.rb', line 36

def increment_success
  raise 'Should be overidden'
end

#indicateObject



23
24
25
26
27
28
29
30
# File 'lib/objects/loading_bar/indicator/base.rb', line 23

def indicate
  print "\n"
  loop do
    increment
    sleep 0.1
    show
  end
end

#showObject



32
33
34
# File 'lib/objects/loading_bar/indicator/base.rb', line 32

def show
  raise 'Should be overidden'
end