Class: GitDB::Utility::CountingIO
- Inherits:
-
Object
- Object
- GitDB::Utility::CountingIO
- Defined in:
- lib/git-db/utility/counting_io.rb
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
Instance Method Summary collapse
- #flush ⇒ Object
-
#initialize(io) ⇒ CountingIO
constructor
A new instance of CountingIO.
- #read(n) ⇒ Object
- #write(data) ⇒ Object
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
#io ⇒ Object (readonly)
Returns the value of attribute io.
3 4 5 |
# File 'lib/git-db/utility/counting_io.rb', line 3 def io @io end |
#offset ⇒ Object (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
#flush ⇒ Object
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 |