Class: Amp::Core::Repositories::Git::TreeObject
- Defined in:
- lib/amp-git/repo_format/tree_object.rb
Overview
TreeObject
This is a tree object representing a versioned directory. It has a list of
Defined Under Namespace
Classes: TreeEntry
Constant Summary
Constants inherited from RawObject
Instance Attribute Summary
Attributes inherited from RawObject
Instance Method Summary collapse
-
#entry_names ⇒ Array<String>
Returns a list of the names of the files/directories (blobs/trees) in the tree.
-
#initialize(hsh, opener, content = nil) ⇒ TreeObject
constructor
Initializes the RawObject.
-
#size ⇒ Fixnum
Returns the number of entries in the directory.
-
#tree_lookup(name) ⇒ TreeEntry
Returns a TreeObject for the given filename in this level of the tree.
Methods inherited from RawObject
Constructor Details
#initialize(hsh, opener, content = nil) ⇒ TreeObject
Initializes the RawObject. Needs a hash to identify it and an opener. The opener should point to the .git directory.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/amp-git/repo_format/tree_object.rb', line 42 def initialize(hsh, opener, content = nil) if content @hash_id, @opener = hsh, opener @type = 'tree' @content = content else super(hsh, opener) end parse! end |
Instance Method Details
#entry_names ⇒ Array<String>
Returns a list of the names of the files/directories (blobs/trees) in the tree
59 60 61 |
# File 'lib/amp-git/repo_format/tree_object.rb', line 59 def entry_names @pairs.keys end |
#size ⇒ Fixnum
Returns the number of entries in the directory.
67 68 69 |
# File 'lib/amp-git/repo_format/tree_object.rb', line 67 def size @pairs.size end |
#tree_lookup(name) ⇒ TreeEntry
Returns a TreeObject for the given filename in this level of the tree.
77 78 79 |
# File 'lib/amp-git/repo_format/tree_object.rb', line 77 def tree_lookup(name) @pairs[name] end |