Module: Gash::Helpers

Included in:
Blob, Tree
Defined in:
lib/gash.rb

Overview

Some common methods used by both Tree and Blob.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#modeObject

Returns the value of attribute mode.



36
37
38
# File 'lib/gash.rb', line 36

def mode
  @mode
end

#parentObject

Returns the value of attribute parent.



36
37
38
# File 'lib/gash.rb', line 36

def parent
  @parent
end

#sha1Object

Returns the value of attribute sha1.



36
37
38
# File 'lib/gash.rb', line 36

def sha1
  @sha1
end

Instance Method Details

#blob?Boolean

Checks if this is a Blob.

Returns:

  • (Boolean)


52
# File 'lib/gash.rb', line 52

def blob?; self.class == Gash::Blob end

#changed!Object

Mark this, and all parents as changed.



58
# File 'lib/gash.rb', line 58

def changed!; @sha1 = nil;parent.changed! end

#changed?Boolean

Checks if this object has been changed (since last commit).

Returns:

  • (Boolean)


56
# File 'lib/gash.rb', line 56

def changed?; !@sha1 end

#gashObject

Returns the Gash-object (top-parent).



60
# File 'lib/gash.rb', line 60

def gash; parent.gash end

#initialize(opts = {}) ⇒ Object

Sets the accessors using a Hash:

tree = Gash::Tree.new(:sha1 => "some thing", :mode => "some thing",
                      :parent => "some parent")
tree.sha1 == "some thing"
tree.mode == "some thing"
tree.parent == "some parent"


45
46
47
48
49
# File 'lib/gash.rb', line 45

def initialize(opts = {})
  opts.each do |key, value|
    send("#{key}=", value)
  end
end

#tree?Boolean

Checks if this is a Tree.

Returns:

  • (Boolean)


54
# File 'lib/gash.rb', line 54

def tree?; self.class == Gash::Tree end