Class: Bcome::LoadingBar::Indicator::Basic

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

Constant Summary

Constants inherited from Base

Bcome::LoadingBar::Indicator::Base::CHARACTERS, Bcome::LoadingBar::Indicator::Base::SIGNAL_FAILURE, Bcome::LoadingBar::Indicator::Base::SIGNAL_STOP, Bcome::LoadingBar::Indicator::Base::SIGNAL_SUCCESS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#indicate

Constructor Details

#initialize(*params) ⇒ Basic

Returns a new instance of Basic.



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

def initialize(*params)
  super
  @progress_colour = :bc_green
end

Instance Attribute Details

#progress_colourObject (readonly)

Returns the value of attribute progress_colour.



21
22
23
# File 'lib/objects/loading_bar/indicator/basic.rb', line 21

def progress_colour
  @progress_colour
end

Instance Method Details

#increment_failureObject



28
29
30
# File 'lib/objects/loading_bar/indicator/basic.rb', line 28

def increment_failure
  @progress_colour = :bc_red
end

#increment_successObject



23
24
25
26
# File 'lib/objects/loading_bar/indicator/basic.rb', line 23

def increment_success
  done = true
  show(done)
end

#progress_prefixObject



17
18
19
# File 'lib/objects/loading_bar/indicator/basic.rb', line 17

def progress_prefix
  "#{@title}\s#{glyph.send(progress_colour)}"
end

#show(done = false) ⇒ Object



12
13
14
15
# File 'lib/objects/loading_bar/indicator/basic.rb', line 12

def show(done = false)
  print "\r#{progress_prefix}#{done ? "\s#{@completed_title}\s" : ''}\s"
rescue ThreadError
end