Class: Sinatra::Streaming::FileStreamer

Inherits:
Object
  • Object
show all
Defined in:
lib/codebutler/sinatra.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options) ⇒ FileStreamer

Returns a new instance of FileStreamer.



225
226
227
# File 'lib/codebutler/sinatra.rb', line 225

def initialize(path, options)
  @path, @options = path, options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



223
224
225
# File 'lib/codebutler/sinatra.rb', line 223

def options
  @options
end

#pathObject (readonly)

Returns the value of attribute path.



223
224
225
# File 'lib/codebutler/sinatra.rb', line 223

def path
  @path
end

Instance Method Details

#eachObject



233
234
235
236
237
238
239
# File 'lib/codebutler/sinatra.rb', line 233

def each
  File.open(path, 'rb') do |file|
    while buf = file.read(options[:buffer_size])
      yield buf
    end
  end
end

#to_result(cx, *args) ⇒ Object



229
230
231
# File 'lib/codebutler/sinatra.rb', line 229

def to_result(cx, *args)
  self
end