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
4557 4558 4559 |
# File 'lib/icfs/web/client.rb', line 4557 def initialize(file) @file = file end |
Instance Method Details
#close ⇒ Object
Close the file
4580 4581 4582 4583 4584 4585 4586 |
# File 'lib/icfs/web/client.rb', line 4580 def close if @file.respond_to?(:close!) @file.close! else @file.close end end |
#each ⇒ Object
Provide body of the file in chunks
4570 4571 4572 4573 4574 |
# File 'lib/icfs/web/client.rb', line 4570 def each while str = @file.read(ChunkSize) yield str end end |