Class: Tus::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/tus/input.rb

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ Input

Returns a new instance of Input.



3
4
5
6
# File 'lib/tus/input.rb', line 3

def initialize(input)
  @input = input
  @bytes_read = 0
end

Instance Method Details

#closeObject



27
28
29
# File 'lib/tus/input.rb', line 27

def close
  # Rack input shouldn't be closed, we just support the interface
end

#eof?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/tus/input.rb', line 14

def eof?
  @bytes_read == size
end

#read(*args) ⇒ Object



8
9
10
11
12
# File 'lib/tus/input.rb', line 8

def read(*args)
  result = @input.read(*args)
  @bytes_read += result.bytesize if result.is_a?(String)
  result
end

#rewindObject



18
19
20
21
# File 'lib/tus/input.rb', line 18

def rewind
  @input.rewind
  @bytes_read = 0
end

#sizeObject



23
24
25
# File 'lib/tus/input.rb', line 23

def size
  @input.size
end