Method: Jabber::FileTransfer::FileSource#read
- Defined in:
- lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/filetransfer.rb
#read(length = 512) ⇒ Object
Because it can_range?, this method implements length checking
97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/vendor/xmpp4r/lib/xmpp4r/bytestreams/helper/filetransfer.rb', line 97 def read(length=512) if @length return nil if @bytes_read >= @length # Already read everything requested if @bytes_read + length > @length # Will we read more than requested? length = @length - @bytes_read # Truncate it! end end buf = @file.read(length) @bytes_read += buf.size if buf buf end |