Parent

Methods

Files

Grit::GitRuby::Internal::FileWindow

Public Class Methods

new(file, version = 1) click to toggle source
# File lib/grit/git-ruby/internal/file_window.rb, line 16
def initialize(file, version = 1)
  @file = file
  @offset = nil
  if version == 2
    @global_offset = 8
  else
    @global_offset = 0
  end
end

Public Instance Methods

[](*idx) click to toggle source
# File lib/grit/git-ruby/internal/file_window.rb, line 30
def [](*idx)
  idx = idx[0] if idx.length == 1
  case idx
  when Range
    offset = idx.first
    len = idx.last - idx.first + idx.exclude_end? ? 0 : 1
  when Fixnum
    offset = idx
    len = nil
  when Array
    offset, len = idx
  else
    raise RuntimeError, "invalid index param: #{idx.class}"
  end
  if @offset != offset
    @file.seek(offset + @global_offset)
  end
  @offset = offset + len ? len : 1
  if not len
    @file.read(1).getord(0)
  else
    @file.read(len)
  end
end
unmap() click to toggle source
# File lib/grit/git-ruby/internal/file_window.rb, line 26
def unmap
  @file = nil
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.