Class: Grit::GitRuby::Object
- Inherits:
-
Object
- Object
- Grit::GitRuby::Object
- Defined in:
- lib/grit/git-ruby/object.rb
Overview
base class for all git objects (blob, tree, commit, tag)
Instance Attribute Summary collapse
-
#repository ⇒ Object
Returns the value of attribute repository.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Object
constructor
A new instance of Object.
- #raw_content ⇒ Object
- #sha1 ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize ⇒ Object
Returns a new instance of Object.
58 59 60 |
# File 'lib/grit/git-ruby/object.rb', line 58 def initialize raise NotImplemented, "abstract class" end |
Instance Attribute Details
#repository ⇒ Object
Returns the value of attribute repository.
41 42 43 |
# File 'lib/grit/git-ruby/object.rb', line 41 def repository @repository end |
Class Method Details
.from_raw(rawobject, repository = nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/grit/git-ruby/object.rb', line 43 def Object.from_raw(rawobject, repository = nil) case rawobject.type when :blob return Blob.from_raw(rawobject, repository) when :tree return Tree.from_raw(rawobject, repository) when :commit return Commit.from_raw(rawobject, repository) when :tag return Tag.from_raw(rawobject, repository) else raise RuntimeError, "got invalid object-type" end end |
Instance Method Details
#raw_content ⇒ Object
66 67 68 |
# File 'lib/grit/git-ruby/object.rb', line 66 def raw_content raise NotImplemented, "abstract class" end |
#sha1 ⇒ Object
70 71 72 73 74 |
# File 'lib/grit/git-ruby/object.rb', line 70 def sha1 Digest::SHA1.hexdigest("%s %d\0" % \ [self.type, self.raw_content.length] + \ self.raw_content) end |
#type ⇒ Object
62 63 64 |
# File 'lib/grit/git-ruby/object.rb', line 62 def type raise NotImplemented, "abstract class" end |