Class: GitObjectBrowser::Models::PackFile

Inherits:
Bindata
  • Object
show all
Defined in:
lib/git-object-browser/models/pack_file.rb

Overview

signature 4bytes PACK

version            4bytes
objects number     4bytes
object entries     -> packed_object.rb

github.com/git/git/blob/master/Documentation/technical/pack-format.txt

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Bindata

#binstr, #byte, #bytes, #find_char, #hex, #int, #peek, #raw, #seek, #skip, #switch_source

Constructor Details

#initialize(input) ⇒ PackFile

Returns a new instance of PackFile.



15
16
17
# File 'lib/git-object-browser/models/pack_file.rb', line 15

def initialize(input)
  super(input)
end

Class Method Details

.path?(relpath) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/git-object-browser/models/pack_file.rb', line 19

def self.path?(relpath)
  return relpath =~ %r{\Aobjects/pack/pack-[0-9a-f]{40}\.pack\z}
end

Instance Method Details

#parseObject



23
24
25
26
27
28
29
# File 'lib/git-object-browser/models/pack_file.rb', line 23

def parse
  signature = raw(4)
  raise 'wrong signature' if signature != 'PACK'
  @version       = int
  @object_number = int
  self
end

#to_hashObject



31
32
33
34
35
36
# File 'lib/git-object-browser/models/pack_file.rb', line 31

def to_hash
  return {
    :version => @version,
    :object_number => @object_number
  }
end