Class: Termite::Progress
- Inherits:
-
Object
- Object
- Termite::Progress
- Defined in:
- lib/termite.rb
Instance Attribute Summary collapse
-
#decorations ⇒ Object
Returns the value of attribute decorations.
-
#desc ⇒ Object
Returns the value of attribute desc.
-
#state ⇒ Object
Returns the value of attribute state.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #bar ⇒ Object
-
#initialize(desc, width = 35, color = false, *deco) ⇒ Progress
constructor
A new instance of Progress.
- #report(s = false) ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize(desc, width = 35, color = false, *deco) ⇒ Progress
Returns a new instance of Progress.
87 88 89 90 91 92 |
# File 'lib/termite.rb', line 87 def initialize( desc, width = 35, color = false, *deco ) @desc = desc @width = width @decorations = deco @decorations << :"fg_#{color}" if color end |
Instance Attribute Details
#decorations ⇒ Object
Returns the value of attribute decorations.
85 86 87 |
# File 'lib/termite.rb', line 85 def decorations @decorations end |
#desc ⇒ Object
Returns the value of attribute desc.
85 86 87 |
# File 'lib/termite.rb', line 85 def desc @desc end |
#state ⇒ Object
Returns the value of attribute state.
85 86 87 |
# File 'lib/termite.rb', line 85 def state @state end |
#width ⇒ Object
Returns the value of attribute width.
85 86 87 |
# File 'lib/termite.rb', line 85 def width @width end |
Instance Method Details
#bar ⇒ Object
103 104 105 106 107 108 109 110 111 |
# File 'lib/termite.rb', line 103 def completed = (@state * @width).to_i remaining = @width - completed Termite.decorate(@bs[0..(completed)], :reverse, *@decorations) + Termite.decorate(@bs[(completed+1)..@width], *@decorations) end |
#report(s = false) ⇒ Object
98 99 100 101 |
# File 'lib/termite.rb', line 98 def report( s = false ) @state = s if s end |
#reset ⇒ Object
94 95 96 |
# File 'lib/termite.rb', line 94 def reset @state = 0.0 end |