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
4691 4692 4693 |
# File 'lib/icfs/web/client.rb', line 4691 def initialize(file) @file = file end |
Instance Method Details
#close ⇒ Object
Close the file
4714 4715 4716 4717 4718 4719 4720 |
# File 'lib/icfs/web/client.rb', line 4714 def close if @file.respond_to?(:close!) @file.close! else @file.close end end |
#each ⇒ Object
Provide body of the file in chunks
4704 4705 4706 4707 4708 |
# File 'lib/icfs/web/client.rb', line 4704 def each while str = @file.read(ChunkSize) yield str end end |