Class: Grit::GitRuby::Internal::RawObject

Inherits:
Object
  • Object
show all
Defined in:
lib/grit/git-ruby/internal/raw_object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, content) ⇒ RawObject

Returns a new instance of RawObject.



26
27
28
29
# File 'lib/grit/git-ruby/internal/raw_object.rb', line 26

def initialize(type, content)
  @type = type
  @content = content
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



25
26
27
# File 'lib/grit/git-ruby/internal/raw_object.rb', line 25

def content
  @content
end

#typeObject

Returns the value of attribute type.



25
26
27
# File 'lib/grit/git-ruby/internal/raw_object.rb', line 25

def type
  @type
end

Instance Method Details

#sha1Object



31
32
33
# File 'lib/grit/git-ruby/internal/raw_object.rb', line 31

def sha1
  Digest::SHA1.digest("%s %d\0" % [@type, @content.length] + @content)
end

#to_hashObject



35
36
37
38
39
40
# File 'lib/grit/git-ruby/internal/raw_object.rb', line 35

def to_hash
  {
    :type => @type,
    :content => @content
  }
end