Class: Derrick::Progress

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(total) ⇒ Progress

Returns a new instance of Progress.



5
6
7
8
9
10
11
# File 'lib/derrick/progress.rb', line 5

def initialize(total)
  @total = total
  @mutex = Mutex.new

  @collected = 0
  @fetched = 0
end

Instance Attribute Details

#collectedObject (readonly)

Returns the value of attribute collected.



3
4
5
# File 'lib/derrick/progress.rb', line 3

def collected
  @collected
end

#fetchedObject (readonly)

Returns the value of attribute fetched.



3
4
5
# File 'lib/derrick/progress.rb', line 3

def fetched
  @fetched
end

#totalObject (readonly)

Returns the value of attribute total.



3
4
5
# File 'lib/derrick/progress.rb', line 3

def total
  @total
end

Instance Method Details

#increment_collected(count) ⇒ Object



13
14
15
# File 'lib/derrick/progress.rb', line 13

def increment_collected(count)
  @mutex.synchronize { @collected += count }
end

#increment_fetched(count) ⇒ Object



17
18
19
# File 'lib/derrick/progress.rb', line 17

def increment_fetched(count)
  @mutex.synchronize { @fetched += count }
end