class Rack::File::Iterator

Attributes

path[R]
range[R]
to_path[R]

Public Class Methods

new(path, range) click to toggle source
# File lib/rack/file.rb, line 108
def initialize path, range
  @path  = path
  @range = range
end

Public Instance Methods

close() click to toggle source
# File lib/rack/file.rb, line 127
def close; end
each() { |part| ... } click to toggle source
# File lib/rack/file.rb, line 113
def each
  ::File.open(path, "rb") do |file|
    file.seek(range.begin)
    remaining_len = range.end-range.begin+1
    while remaining_len > 0
      part = file.read([8192, remaining_len].min)
      break unless part
      remaining_len -= part.length

      yield part
    end
  end
end