Class: Echo::ProgressBar
- Inherits:
-
Object
- Object
- Echo::ProgressBar
- Defined in:
- lib/rake-echo.rb
Instance Attribute Summary collapse
-
#current ⇒ Object
readonly
Returns the value of attribute current.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #completed? ⇒ Boolean
- #increment(amount = 1) ⇒ Object
-
#initialize(total) ⇒ ProgressBar
constructor
A new instance of ProgressBar.
- #percentage ⇒ Object
Constructor Details
#initialize(total) ⇒ ProgressBar
Returns a new instance of ProgressBar.
8 9 10 11 12 13 |
# File 'lib/rake-echo.rb', line 8 def initialize(total) @total = total @current = 0 @start_time = Time.now @previous_time = @start_time end |
Instance Attribute Details
#current ⇒ Object (readonly)
Returns the value of attribute current.
5 6 7 |
# File 'lib/rake-echo.rb', line 5 def current @current end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
6 7 8 |
# File 'lib/rake-echo.rb', line 6 def start_time @start_time end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
4 5 6 |
# File 'lib/rake-echo.rb', line 4 def total @total end |
Instance Method Details
#completed? ⇒ Boolean
26 27 28 |
# File 'lib/rake-echo.rb', line 26 def completed? @current == @total end |
#increment(amount = 1) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/rake-echo.rb', line 15 def increment(amount=1) @current += amount display finish if completed? end |
#percentage ⇒ Object
22 23 24 |
# File 'lib/rake-echo.rb', line 22 def percentage current.to_f / total.to_f end |