Class: FBO::ChunkedFile

Inherits:
File
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/fbo/chunked_file.rb

Constant Summary collapse

DEFAULT_CHUNK_SIZE =

250KB

250 * 1024

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from File

filename_for_date, #gets

Constructor Details

#initialize(file, chunk_size = DEFAULT_CHUNK_SIZE) ⇒ ChunkedFile

Returns a new instance of ChunkedFile.



14
15
16
17
# File 'lib/fbo/chunked_file.rb', line 14

def initialize(file, chunk_size = DEFAULT_CHUNK_SIZE)
  @file = file
  @chunk_size = chunk_size
end

Instance Attribute Details

#chunk_sizeObject (readonly)

Returns the value of attribute chunk_size.



7
8
9
# File 'lib/fbo/chunked_file.rb', line 7

def chunk_size
  @chunk_size
end

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/fbo/chunked_file.rb', line 7

def file
  @file
end

Instance Method Details

#contentsObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/fbo/chunked_file.rb', line 19

def contents
  if @contents.nil?
    @contents = []
    while !eof
      @contents << next_chunk
    end
    @contents.compact!
  end
  @contents
end