Class: ICFS::Web::FileResp
- Inherits:
-
Object
- Object
- ICFS::Web::FileResp
- Defined in:
- lib/icfs/web/client.rb
Overview
A file response object to use in Rack
Constant Summary collapse
- ChunkSize =
Chunk size of 64 kB
1024 * 64
Instance Method Summary collapse
-
#close ⇒ Object
Close the file.
-
#each ⇒ Object
Provide body of the file in chunks.
-
#initialize(file) ⇒ FileResp
constructor
New response.
Constructor Details
#initialize(file) ⇒ FileResp
New response
4549 4550 4551 |
# File 'lib/icfs/web/client.rb', line 4549 def initialize(file) @file = file end |
Instance Method Details
#close ⇒ Object
Close the file
4572 4573 4574 4575 4576 4577 4578 |
# File 'lib/icfs/web/client.rb', line 4572 def close if @file.respond_to?(:close!) @file.close! else @file.close end end |
#each ⇒ Object
Provide body of the file in chunks
4562 4563 4564 4565 4566 |
# File 'lib/icfs/web/client.rb', line 4562 def each while str = @file.read(ChunkSize) yield str end end |