Class: Operation::Progress
- Inherits:
-
Object
- Object
- Operation::Progress
- Defined in:
- lib/operation/progress.rb
Instance Method Summary collapse
- #code ⇒ Object
-
#initialize(percent, code = nil) ⇒ Progress
constructor
A new instance of Progress.
- #of(total) ⇒ Object
- #percent ⇒ Object
Constructor Details
#initialize(percent, code = nil) ⇒ Progress
Returns a new instance of Progress.
4 5 6 |
# File 'lib/operation/progress.rb', line 4 def initialize(percent, code = nil) @percent, @code = percent, code end |
Instance Method Details
#code ⇒ Object
12 13 14 15 |
# File 'lib/operation/progress.rb', line 12 def code return if @code.to_s == '' @code.to_s.to_sym end |
#of(total) ⇒ Object
17 18 19 20 |
# File 'lib/operation/progress.rb', line 17 def of(total) partial_percent = (percent.to_f / total.to_i).to_i self.class.new partial_percent, code end |
#percent ⇒ Object
8 9 10 |
# File 'lib/operation/progress.rb', line 8 def percent @percent.to_i end |