Class: Tus::Input
- Inherits:
-
Object
- Object
- Tus::Input
- Defined in:
- lib/tus/input.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(input, limit: nil) ⇒ Input
constructor
A new instance of Input.
- #pos ⇒ Object
- #read(length = nil, outbuf = nil) ⇒ Object
- #rewind ⇒ Object
Constructor Details
#initialize(input, limit: nil) ⇒ Input
Returns a new instance of Input.
6 7 8 9 10 |
# File 'lib/tus/input.rb', line 6 def initialize(input, limit: nil) @input = input @limit = limit @pos = 0 end |
Instance Method Details
#close ⇒ Object
34 35 36 |
# File 'lib/tus/input.rb', line 34 def close # Rack input shouldn't be closed, we just support the interface end |
#pos ⇒ Object
25 26 27 |
# File 'lib/tus/input.rb', line 25 def pos @pos end |
#read(length = nil, outbuf = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/tus/input.rb', line 12 def read(length = nil, outbuf = nil) data = @input.read(length, outbuf) @pos += data.bytesize if data raise MaxSizeExceeded if @limit && @pos > @limit data rescue => exception raise unless exception.class.name == "Unicorn::ClientShutdown" outbuf = outbuf.to_s.clear outbuf unless length end |
#rewind ⇒ Object
29 30 31 32 |
# File 'lib/tus/input.rb', line 29 def rewind @input.rewind @pos = 0 end |