Class: Gitrb::FileWindow

Inherits:
Object
  • Object
show all
Defined in:
lib/gitrb/pack.rb

Instance Method Summary collapse

Constructor Details

#initialize(file, version = 1) ⇒ FileWindow

Returns a new instance of FileWindow.



15
16
17
18
19
20
21
22
23
# File 'lib/gitrb/pack.rb', line 15

def initialize(file, version = 1)
  @file = file
  @offset = nil
  if version == 2
    @global_offset = 8
  else
    @global_offset = 0
  end
end

Instance Method Details

#[](offset, len) ⇒ Object



25
26
27
28
29
# File 'lib/gitrb/pack.rb', line 25

def [](offset, len)
  @file.seek(offset + @global_offset) if @offset != offset
  @offset = offset + len
  @file.read(len)
end