class EventMachine::Zipper::Entry

Attributes

chunks[R]
file_path[R]
out[R]

Public Class Methods

new(file_path, chunks, out) click to toggle source
# File lib/em-zipper/entry.rb, line 8
def initialize(file_path, chunks, out)
  @file_path = file_path
  @chunks    = chunks
  @out       = out
end

Public Instance Methods

write!() click to toggle source
# File lib/em-zipper/entry.rb, line 14
def write!
  create_entry
  EM.next_tick { chunks.pop(&write_chunks) }

  self
end

Private Instance Methods

create_entry() click to toggle source
# File lib/em-zipper/entry.rb, line 40
def create_entry
  new_entry = ::Zip::ZipEntry.new '-', file_name
  out.put_next_entry(new_entry)
end
file_name() click to toggle source
# File lib/em-zipper/entry.rb, line 36
def file_name
  @file_namem ||= File.basename file_path
end
write_chunks() click to toggle source
# File lib/em-zipper/entry.rb, line 24
def write_chunks
  proc do |chunk|
    out << chunk

    if chunks.empty?
      EM.next_tick { succeed }
    else
      EM.next_tick { chunks.pop(&write_chunks) }
    end
  end
end