Class: S3DataPacker::Summary
- Inherits:
-
Object
- Object
- S3DataPacker::Summary
- Defined in:
- lib/s3_data_packer/summary.rb
Instance Method Summary collapse
- #batches ⇒ Object
- #count_batch ⇒ Object
- #count_item ⇒ Object
- #count_processed ⇒ Object
- #elapsed ⇒ Object
- #flush! ⇒ Object
- #processed ⇒ Object
- #reset! ⇒ Object
- #set_time(start_time, end_time) ⇒ Object
- #stats ⇒ Object
- #total_items ⇒ Object
Instance Method Details
#batches ⇒ Object
34 35 36 |
# File 'lib/s3_data_packer/summary.rb', line 34 def batches stats[:batches] || 0 end |
#count_batch ⇒ Object
17 18 19 20 |
# File 'lib/s3_data_packer/summary.rb', line 17 def count_batch stats[:batches] ||= 0 stats[:batches] += 1 end |
#count_item ⇒ Object
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_processed ⇒ Object
12 13 14 15 |
# File 'lib/s3_data_packer/summary.rb', line 12 def count_processed stats[:processed] ||= 0 stats[:processed] += 1 end |
#elapsed ⇒ Object
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 |
#processed ⇒ Object
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 |
#stats ⇒ Object
3 4 5 |
# File 'lib/s3_data_packer/summary.rb', line 3 def stats @stats ||= {} end |
#total_items ⇒ Object
26 27 28 |
# File 'lib/s3_data_packer/summary.rb', line 26 def total_items stats[:total_items] || 0 end |