Class: SimpleGit::Tree

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_git/tree.rb

Defined Under Namespace

Classes: TreeWrapper

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ptrObject

Returns the value of attribute ptr.



3
4
5
# File 'lib/simple_git/tree.rb', line 3

def ptr
  @ptr
end

Class Method Details

.finalize(ptr) ⇒ Object



17
18
19
# File 'lib/simple_git/tree.rb', line 17

def self.finalize(ptr)
  proc { Git2.git_tree_free(ptr) }
end

Instance Method Details

#from_commit(commit) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/simple_git/tree.rb', line 5

def from_commit(commit)
  wrapper = TreeWrapper.new
  Git2.git_commit_tree(wrapper, commit.ptr)

  @ptr = wrapper[:tree]
  ObjectSpace.define_finalizer(self, self.class.finalize(@ptr))

  self
end