Class: GitSniffer::Object

Inherits:
Object
  • Object
show all
Includes:
Hook, Lazy
Defined in:
lib/git_sniffer/object.rb

Direct Known Subclasses

Blob, Commit, Tree

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Lazy

included

Methods included from Hook

included

Constructor Details

#initialize(base, sha) ⇒ Object

Returns a new instance of Object.



13
14
15
16
# File 'lib/git_sniffer/object.rb', line 13

def initialize(base, sha)
	@base = base
	@sha = sha
end

Instance Attribute Details

#shaObject (readonly)

Returns the value of attribute sha.



9
10
11
# File 'lib/git_sniffer/object.rb', line 9

def sha
  @sha
end

Class Method Details

.create_object(base, sha) ⇒ Object



35
36
37
# File 'lib/git_sniffer/object.rb', line 35

def create_object(base, sha)
	eval("GitSniffer::#{object_type(base, sha)}").new(base, sha)		
end

.object_type(base, sha) ⇒ Object



39
40
41
# File 'lib/git_sniffer/object.rb', line 39

def object_type(base, sha)
	base.exec("cat-file -t #{sha}").chomp.capitalize
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/git_sniffer/object.rb', line 30

def eql?(other)
	self.class.equal?(other.class) && @sha == other.sha
end

#hashObject



26
27
28
# File 'lib/git_sniffer/object.rb', line 26

def hash
	@sha.hash
end

#lazy_content_sourceObject



22
23
24
# File 'lib/git_sniffer/object.rb', line 22

def lazy_content_source
	@base.exec("cat-file -p #{@sha}")
end

#lazy_type_sourceObject



18
19
20
# File 'lib/git_sniffer/object.rb', line 18

def lazy_type_source
	@base.exec("cat-file -t #{@sha}").chomp
end