Class: RocketJob::Sliced::Output

Inherits:
Slices
  • Object
show all
Defined in:
lib/rocket_job/sliced/output.rb

Instance Attribute Summary

Attributes inherited from Slices

#all, #collection_name, #slice_class, #slice_size

Instance Method Summary collapse

Methods inherited from Slices

#append, #completed, #create, #create!, #create_indexes, #drop, #each, #failed, #first, #group_exceptions, #initialize, #insert, #insert_many, #last, #new, #queued, #running

Constructor Details

This class inherits a constructor from RocketJob::Sliced::Slices

Instance Method Details

#download(header_line: nil) {|header_line| ... } ⇒ Object

Yields:

  • (header_line)

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rocket_job/sliced/output.rb', line 6

def download(header_line: nil)
  raise(ArgumentError, "Block is mandatory") unless block_given?

  # Write the header line
  yield(header_line) if header_line

  # Call the supplied block for every record returned
  record_count = 0
  each do |slice|
    # TODO: Add slice_id to named tags to aid problem determination
    slice.each do |record|
      record_count += 1
      yield(record)
    end
  end
  record_count
end