Class: Datanorm::Progress

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from Logging

included

Instance Attribute Details

#currentObject

Returns the value of attribute current.



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

def current
  @current
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#totalObject

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

#percentageObject



22
23
24
# File 'lib/datanorm/progress.rb', line 22

def percentage
  ((current.to_f / total) * 100).round(1)
end

#significant?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/datanorm/progress.rb', line 18

def significant?
  (current % 50_000).zero?
end

#to_sObject



14
15
16
# File 'lib/datanorm/progress.rb', line 14

def to_s
  "#{percentage}% (#{title} #{current}/#{total})"
end