Class: ProgressStream

Inherits:
Object
  • Object
show all
Defined in:
lib/rvc/util.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, len, &b) ⇒ ProgressStream

Returns a new instance of ProgressStream.



408
409
410
411
412
413
# File 'lib/rvc/util.rb', line 408

def initialize io, len, &b
  @io = io
  @len = len
  @count = 0
  @cb = b
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



406
407
408
# File 'lib/rvc/util.rb', line 406

def count
  @count
end

#ioObject (readonly)

Returns the value of attribute io.



406
407
408
# File 'lib/rvc/util.rb', line 406

def io
  @io
end

#lenObject (readonly)

Returns the value of attribute len.



406
407
408
# File 'lib/rvc/util.rb', line 406

def len
  @len
end

Instance Method Details

#read(n) ⇒ Object



415
416
417
418
419
420
# File 'lib/rvc/util.rb', line 415

def read n
  io.read(n).tap do |c|
    @count += c.length if c
    @cb[self]
  end
end