Class: ProgressStream

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ProgressStream.



105
106
107
108
109
110
# File 'lib/rvc/modules/datastore.rb', line 105

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.



103
104
105
# File 'lib/rvc/modules/datastore.rb', line 103

def count
  @count
end

#ioObject (readonly)

Returns the value of attribute io.



103
104
105
# File 'lib/rvc/modules/datastore.rb', line 103

def io
  @io
end

#lenObject (readonly)

Returns the value of attribute len.



103
104
105
# File 'lib/rvc/modules/datastore.rb', line 103

def len
  @len
end

Instance Method Details

#read(n) ⇒ Object



112
113
114
115
116
117
# File 'lib/rvc/modules/datastore.rb', line 112

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