Class: GitDB::Objects::Tree

Inherits:
Base
  • Object
show all
Defined in:
lib/git-db/objects/tree.rb

Instance Attribute Summary

Attributes inherited from Base

#data

Instance Method Summary collapse

Methods inherited from Base

#initialize, #inspect, #sha

Constructor Details

This class inherits a constructor from GitDB::Objects::Base

Instance Method Details

#entriesObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/git-db/objects/tree.rb', line 5

def entries
  @entries ||= begin
    entries = []
    stream = StringIO.new(data)
    until stream.eof?
      perms = read_until(stream, ' ').to_i
      name  = read_until(stream, 0.chr)
      sha   = GitDB.sha1_to_hex(stream.read(20))
      entries << GitDB::Objects::Entry.new(sha, perms, name)
    end
    entries
  end
end

#propertiesObject



19
20
21
# File 'lib/git-db/objects/tree.rb', line 19

def properties
  [:entries]
end

#rawObject



23
24
25
# File 'lib/git-db/objects/tree.rb', line 23

def raw
  "tree #{data.length}\000#{data}"
end

#typeObject



27
28
29
# File 'lib/git-db/objects/tree.rb', line 27

def type
  GitDB::OBJ_TREE
end