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
4809 4810 4811 |
# File 'lib/icfs/web/client.rb', line 4809 def initialize(file) @file = file end |
Instance Method Details
#close ⇒ Object
Close the file
4832 4833 4834 4835 4836 4837 4838 |
# File 'lib/icfs/web/client.rb', line 4832 def close if @file.respond_to?(:close!) @file.close! else @file.close end end |
#each ⇒ Object
Provide body of the file in chunks
4822 4823 4824 4825 4826 |
# File 'lib/icfs/web/client.rb', line 4822 def each while str = @file.read(ChunkSize) yield str end end |