Class: Grack::FileStreamer
- Inherits:
-
IOStreamer
- Object
- IOStreamer
- Grack::FileStreamer
- Defined in:
- lib/grack/file_streamer.rb
Overview
A Rack body implementation that streams a given file in chunks for a Rack response.
Constant Summary
Constants inherited from IOStreamer
Instance Method Summary collapse
-
#initialize(path) ⇒ FileStreamer
constructor
Creates a new instance of this object.
-
#mtime ⇒ Object
The last modified time to report for the Rack response.
-
#to_path ⇒ String
In order to support X-Sendfile when available, this method returns the path to the file the web server would use to provide the content.
- #with_io {|io| ... } ⇒ Object private
Methods inherited from IOStreamer
Constructor Details
#initialize(path) ⇒ FileStreamer
Creates a new instance of this object.
14 15 16 |
# File 'lib/grack/file_streamer.rb', line 14 def initialize(path) @path = Pathname.new(path). end |
Instance Method Details
#mtime ⇒ Object
The last modified time to report for the Rack response.
29 30 31 |
# File 'lib/grack/file_streamer.rb', line 29 def mtime @path.mtime end |
#to_path ⇒ String
In order to support X-Sendfile when available, this method returns the path to the file the web server would use to provide the content.
23 24 25 |
# File 'lib/grack/file_streamer.rb', line 23 def to_path @path.to_s end |
#with_io {|io| ... } ⇒ Object (private)
37 38 39 |
# File 'lib/grack/file_streamer.rb', line 37 def with_io(&b) @path.open(&b) end |