Sha256: fac486b12963bf724e43c94f41a29394cd58d378698b7dc614e1c30cf97aed3d
Contents?: true
Size: 862 Bytes
Versions: 2
Compression:
Stored size: 862 Bytes
Contents
module Defile class File attr_reader :backend, :id def initialize(backend, id) @backend = backend @id = id end def read(*args) io.read(*args) end def eof? io.eof? end def close io.close end def size backend.size(id) end def delete backend.delete(id) end def exists? backend.exists?(id) end def to_io io end def download tempfile = Tempfile.new(id) tempfile.binmode each do |chunk| tempfile.write(chunk) end close tempfile.close tempfile end def each if block_given? until eof? yield(read(Defile.read_chunk_size)) end else to_enum end end private def io @io ||= backend.open(id) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
defile-0.2.1 | lib/defile/file.rb |
defile-0.2.0 | lib/defile/file.rb |