Class: Datanorm::Progress
- Inherits:
-
Object
- Object
- Datanorm::Progress
- Includes:
- Logging
- Defined in:
- lib/datanorm/progress.rb
Overview
Represents how much processing elapsed and how much is left to be done.
Instance Attribute Summary collapse
-
#current ⇒ Object
Returns the value of attribute current.
-
#title ⇒ Object
Returns the value of attribute title.
-
#total ⇒ Object
Returns the value of attribute total.
Instance Method Summary collapse
Methods included from Logging
Instance Attribute Details
#current ⇒ Object
Returns the value of attribute current.
8 9 10 |
# File 'lib/datanorm/progress.rb', line 8 def current @current end |
#title ⇒ Object
Returns the value of attribute title.
8 9 10 |
# File 'lib/datanorm/progress.rb', line 8 def title @title end |
#total ⇒ Object
Returns the value of attribute total.
8 9 10 |
# File 'lib/datanorm/progress.rb', line 8 def total @total end |
Instance Method Details
#increment! ⇒ Object
10 11 12 |
# File 'lib/datanorm/progress.rb', line 10 def increment! self.current += 1 end |
#percentage ⇒ Object
22 23 24 |
# File 'lib/datanorm/progress.rb', line 22 def percentage ((current.to_f / total) * 100).round(1) end |
#significant? ⇒ Boolean
18 19 20 |
# File 'lib/datanorm/progress.rb', line 18 def significant? (current % 50_000).zero? end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/datanorm/progress.rb', line 14 def to_s "#{percentage}% (#{title} #{current}/#{total})" end |