Class: Rbar::Bars::BaseBar

Inherits:
Object
  • Object
show all
Defined in:
lib/rbar/bars/base_bar.rb

Direct Known Subclasses

Failed, Passing, Pending

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent_bar:, total:, count: 0) ⇒ BaseBar



8
9
10
11
12
13
# File 'lib/rbar/bars/base_bar.rb', line 8

def initialize(parent_bar:, total:, count: 0)
  @total = total
  @parent_bar = parent_bar
  @count = count
  @progress_bar = register_self
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



35
36
37
# File 'lib/rbar/bars/base_bar.rb', line 35

def count
  @count
end

#parent_barObject (readonly)

Returns the value of attribute parent_bar.



35
36
37
# File 'lib/rbar/bars/base_bar.rb', line 35

def parent_bar
  @parent_bar
end

#progress_barObject (readonly)

Returns the value of attribute progress_bar.



35
36
37
# File 'lib/rbar/bars/base_bar.rb', line 35

def progress_bar
  @progress_bar
end

#totalObject (readonly)

Returns the value of attribute total.



35
36
37
# File 'lib/rbar/bars/base_bar.rb', line 35

def total
  @total
end

Instance Method Details

#incrementObject



15
16
17
18
# File 'lib/rbar/bars/base_bar.rb', line 15

def increment
  increment_count
  increment_bar
end

#progressObject



31
32
33
# File 'lib/rbar/bars/base_bar.rb', line 31

def progress
  progress_bar.current
end

#register_selfObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/rbar/bars/base_bar.rb', line 20

def register_self
  bar = parent_bar.register(format,
    bar_format: :square,
    total: total,
    count: "0",
    width: TTY::Screen.width * 0.75,
    complete: color)
  bar.start
  bar
end