Class: Schlepp::Sink::Filter::Chunker

Inherits:
Object
  • Object
show all
Defined in:
lib/schlepp/sink/filter/chunker.rb

Defined Under Namespace

Classes: Builder

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Chunker

Returns a new instance of Chunker.



16
17
18
19
20
# File 'lib/schlepp/sink/filter/chunker.rb', line 16

def initialize(opts = {})
  @chunk = 0
  @chunk_size = opts[:chunk_size] || 100000
  @observer = Schlepp::Sink::TableObject::Filter::Observer.new
end

Instance Method Details

#extensionObject



22
23
24
# File 'lib/schlepp/sink/filter/chunker.rb', line 22

def extension
  @chunk.to_s
end

#rotateObject



30
31
32
# File 'lib/schlepp/sink/filter/chunker.rb', line 30

def rotate
  @chunk += 1
end

#should_rotate?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/schlepp/sink/filter/chunker.rb', line 26

def should_rotate?
  @observer.count > @chunk_size
end

#writerObject



34
35
36
# File 'lib/schlepp/sink/filter/chunker.rb', line 34

def writer
  @builder ||= Builder.new(@observer)
end