Class: S3DataPacker::Summary

Inherits:
Object
  • Object
show all
Defined in:
lib/s3_data_packer/summary.rb

Instance Method Summary collapse

Instance Method Details

#batchesObject



34
35
36
# File 'lib/s3_data_packer/summary.rb', line 34

def batches
  stats[:batches] || 0
end

#count_batchObject



17
18
19
20
# File 'lib/s3_data_packer/summary.rb', line 17

def count_batch
  stats[:batches] ||= 0
  stats[:batches] += 1
end

#count_itemObject



7
8
9
10
# File 'lib/s3_data_packer/summary.rb', line 7

def count_item
  stats[:total_items] ||= 0
  stats[:total_items] += 1
end

#count_processedObject



12
13
14
15
# File 'lib/s3_data_packer/summary.rb', line 12

def count_processed
  stats[:processed] ||= 0
  stats[:processed] += 1
end

#elapsedObject



38
39
40
# File 'lib/s3_data_packer/summary.rb', line 38

def elapsed
  stats[:elapsed]
end

#flush!Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/s3_data_packer/summary.rb', line 42

def flush!
  output = [
    "Summary:",
    "Total Items: #{stats[:total_items]}",
    "Processed Items: #{stats[:processed]}",
    "Batches: #{stats[:batches]}",
    "Elapsed: #{stats[:elapsed]}"
  ].join("\n")
  reset!
  output
end

#processedObject



30
31
32
# File 'lib/s3_data_packer/summary.rb', line 30

def processed
  stats[:processed] || 0
end

#reset!Object



54
55
56
# File 'lib/s3_data_packer/summary.rb', line 54

def reset!
  @stats = {}
end

#set_time(start_time, end_time) ⇒ Object



22
23
24
# File 'lib/s3_data_packer/summary.rb', line 22

def set_time start_time, end_time
  stats[:elapsed] = "#{(end_time.to_i - start_time.to_i)} seconds"
end

#statsObject



3
4
5
# File 'lib/s3_data_packer/summary.rb', line 3

def stats
  @stats ||= {}
end

#total_itemsObject



26
27
28
# File 'lib/s3_data_packer/summary.rb', line 26

def total_items
  stats[:total_items] || 0
end