Class: IntervalResponse::LazyFile
- Inherits:
-
Object
- Object
- IntervalResponse::LazyFile
- Defined in:
- lib/interval_response/lazy_file.rb
Overview
Used so that if a sequence of files gets served out, the files should not be kept open during the entire response output - as this might exhaust the file descriptor table
Instance Method Summary collapse
-
#initialize(filesystem_path) ⇒ LazyFile
constructor
A new instance of LazyFile.
- #size ⇒ Object
- #with ⇒ Object
Constructor Details
#initialize(filesystem_path) ⇒ LazyFile
Returns a new instance of LazyFile.
6 7 8 |
# File 'lib/interval_response/lazy_file.rb', line 6 def initialize(filesystem_path) @fs_path = filesystem_path end |
Instance Method Details
#size ⇒ Object
10 11 12 |
# File 'lib/interval_response/lazy_file.rb', line 10 def size File.size(@fs_path) end |
#with ⇒ Object
14 15 16 17 18 |
# File 'lib/interval_response/lazy_file.rb', line 14 def with File.open(@fs_path, 'rb') do |file_handle| yield file_handle end end |