Sha256: 6e4df998ea0e5637f0b270d4a651139cb8c217c7c03cea15da8836e6ba9aad34
Contents?: true
Size: 544 Bytes
Versions: 22
Compression:
Stored size: 544 Bytes
Contents
class Rack::App::File::Streamer include Enumerable def each(&block) file { |f| f.each(&block) } end def render(object=nil) file { |f| f.read } end def mtime(object=nil) ::File.mtime(@file_path).httpdate end def length(object=nil) ::Rack::Utils.bytesize(render()) end protected def initialize(file_path) @file_path = file_path @file = File.open(file_path) end def file(&block) @file.reopen(@file_path) if @file.closed? return block.call(@file) ensure @file.close end end
Version data entries
22 entries across 22 versions & 1 rubygems