Class: UploadProgress
- Inherits:
-
Object
- Object
- UploadProgress
- Defined in:
- lib/vpsmatrix/upload_progress.rb
Overview
the code is used from gem ‘net-http-uploadprogress’
Instance Attribute Summary collapse
-
#upload_size ⇒ Object
readonly
Returns the value of attribute upload_size.
Instance Method Summary collapse
-
#initialize(req, &block) ⇒ UploadProgress
constructor
A new instance of UploadProgress.
- #readpartial(maxlen, outbuf) ⇒ Object
Constructor Details
#initialize(req, &block) ⇒ UploadProgress
Returns a new instance of UploadProgress.
6 7 8 9 10 11 12 |
# File 'lib/vpsmatrix/upload_progress.rb', line 6 def initialize(req, &block) @req = req @callback = block @upload_size = 0 @io = req.body_stream req.body_stream = self end |
Instance Attribute Details
#upload_size ⇒ Object (readonly)
Returns the value of attribute upload_size.
4 5 6 |
# File 'lib/vpsmatrix/upload_progress.rb', line 4 def upload_size @upload_size end |
Instance Method Details
#readpartial(maxlen, outbuf) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/vpsmatrix/upload_progress.rb', line 14 def readpartial(maxlen, outbuf) begin str = @io.readpartial(maxlen, outbuf) ensure @callback.call(self) unless @upload_size.zero? end @upload_size += str.length str end |