Class: CloudEncryptedSync::ProgressMeter
- Inherits:
-
Object
- Object
- CloudEncryptedSync::ProgressMeter
- Defined in:
- lib/cloud_encrypted_sync/progress_meter.rb
Instance Attribute Summary collapse
-
#completed_index ⇒ Object
Returns the value of attribute completed_index.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#max_index ⇒ Object
readonly
Returns the value of attribute max_index.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
Instance Method Summary collapse
- #estimated_finish_time ⇒ Object
- #estimated_time_remaining ⇒ Object
- #increment_completed_index(amount = 1) ⇒ Object
-
#initialize(max_index, options = {}) {|_self| ... } ⇒ ProgressMeter
constructor
A new instance of ProgressMeter.
- #percent_completed ⇒ Object
- #time_elapsed ⇒ Object
Constructor Details
#initialize(max_index, options = {}) {|_self| ... } ⇒ ProgressMeter
Returns a new instance of ProgressMeter.
6 7 8 9 10 11 12 |
# File 'lib/cloud_encrypted_sync/progress_meter.rb', line 6 def initialize(max_index, = {}) @max_index = max_index.to_f @label = [:label] || '' @completed_index = 0.0 @start_time = Time.now yield self if block_given? end |
Instance Attribute Details
#completed_index ⇒ Object
Returns the value of attribute completed_index.
3 4 5 |
# File 'lib/cloud_encrypted_sync/progress_meter.rb', line 3 def completed_index @completed_index end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
4 5 6 |
# File 'lib/cloud_encrypted_sync/progress_meter.rb', line 4 def label @label end |
#max_index ⇒ Object (readonly)
Returns the value of attribute max_index.
4 5 6 |
# File 'lib/cloud_encrypted_sync/progress_meter.rb', line 4 def max_index @max_index end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
4 5 6 |
# File 'lib/cloud_encrypted_sync/progress_meter.rb', line 4 def start_time @start_time end |
Instance Method Details
#estimated_finish_time ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/cloud_encrypted_sync/progress_meter.rb', line 18 def estimated_finish_time if percent_completed > 0 start_time + ((100/percent_completed)*time_elapsed) else start_time + 3600 end end |
#estimated_time_remaining ⇒ Object
14 15 16 |
# File 'lib/cloud_encrypted_sync/progress_meter.rb', line 14 def estimated_time_remaining Time.at(estimated_finish_time - Time.now) end |
#increment_completed_index(amount = 1) ⇒ Object
34 35 36 37 |
# File 'lib/cloud_encrypted_sync/progress_meter.rb', line 34 def increment_completed_index(amount = 1) self.completed_index += amount notify end |
#percent_completed ⇒ Object
26 27 28 |
# File 'lib/cloud_encrypted_sync/progress_meter.rb', line 26 def percent_completed (completed_index/max_index)*100 end |
#time_elapsed ⇒ Object
30 31 32 |
# File 'lib/cloud_encrypted_sync/progress_meter.rb', line 30 def time_elapsed Time.now - start_time end |