Class: Operation::Progress

Inherits:
Object
  • Object
show all
Defined in:
lib/operation/progress.rb

Instance Method Summary collapse

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

#codeObject



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

#percentObject



8
9
10
# File 'lib/operation/progress.rb', line 8

def percent
  @percent.to_i
end