Class: Luck::DoubleProgressBar

Inherits:
ProgressBar show all
Defined in:
lib/luck/progressbar.rb

Instance Attribute Summary collapse

Attributes inherited from ProgressBar

#arrow, #bar, #blank, #maximum, #postcap, #precap, #value

Attributes inherited from Control

#display, #pane, #x1, #x2, #y1, #y2

Instance Method Summary collapse

Methods inherited from ProgressBar

#percentage

Methods inherited from Control

#focus!, #height, #width

Constructor Details

#initialize(*args) ⇒ DoubleProgressBar

Returns a new instance of DoubleProgressBar.



33
34
35
36
37
38
39
# File 'lib/luck/progressbar.rb', line 33

def initialize *args
  @maximum2 = 1
  @value2 = 0
  @bar2 = '-'
  @arrow2 = '>'
  super
end

Instance Attribute Details

#arrow2Object

Returns the value of attribute arrow2.



31
32
33
# File 'lib/luck/progressbar.rb', line 31

def arrow2
  @arrow2
end

#bar2Object

Returns the value of attribute bar2.



31
32
33
# File 'lib/luck/progressbar.rb', line 31

def bar2
  @bar2
end

#maximum2Object

Returns the value of attribute maximum2.



31
32
33
# File 'lib/luck/progressbar.rb', line 31

def maximum2
  @maximum2
end

#value2Object

Returns the value of attribute value2.



31
32
33
# File 'lib/luck/progressbar.rb', line 31

def value2
  @value2
end

Instance Method Details

#percentage2Object



41
42
43
44
# File 'lib/luck/progressbar.rb', line 41

def percentage2
  return 0 if @maximum2 == 0
  @value2.to_f / @maximum2.to_f
end

#redrawObject



50
51
52
53
# File 'lib/luck/progressbar.rb', line 50

def redraw
  super
  @display.place y1, x1, @precap + (@bar2 * (percentage2 * (width - @precap.size - @postcap.size)) + @arrow2)
end

#template(str) ⇒ Object



46
47
48
# File 'lib/luck/progressbar.rb', line 46

def template str
  @precap, @bar2, @arrow2, @bar, @arrow, @blank, @postcap = str.unpack 'aaaaaaa'
end