Class: GitDB::Utility::CountingIO

Inherits:
Object
  • Object
show all
Defined in:
lib/git-db/utility/counting_io.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ CountingIO

Returns a new instance of CountingIO


5
6
7
8
# File 'lib/git-db/utility/counting_io.rb', line 5

def initialize(io)
  @io = io
  @offset = 0
end

Instance Attribute Details

#ioObject (readonly)

Returns the value of attribute io


3
4
5
# File 'lib/git-db/utility/counting_io.rb', line 3

def io
  @io
end

#offsetObject (readonly)

Returns the value of attribute offset


3
4
5
# File 'lib/git-db/utility/counting_io.rb', line 3

def offset
  @offset
end

Instance Method Details

#flushObject


10
11
12
# File 'lib/git-db/utility/counting_io.rb', line 10

def flush
  io.flush
end

#read(n) ⇒ Object


14
15
16
17
18
# File 'lib/git-db/utility/counting_io.rb', line 14

def read(n)
  data = io.read(n)
  @offset += n
  data
end

#write(data) ⇒ Object


20
21
22
# File 'lib/git-db/utility/counting_io.rb', line 20

def write(data)
  io.write(data)
end