Class: Grit::Ref

Inherits:
Object
  • Object
show all
Defined in:
lib/grit/ref.rb

Direct Known Subclasses

Head, Note, Remote, Tag

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, commit) ⇒ Ref

Instantiate a new Head

+name+ is the name of the head
+commit+ is the Commit that the head points to

Returns Grit::Head (baked)



37
38
39
40
# File 'lib/grit/ref.rb', line 37

def initialize(name, commit)
  @name = name
  @commit = commit
end

Instance Attribute Details

#commitObject (readonly)

Returns the value of attribute commit.



30
31
32
# File 'lib/grit/ref.rb', line 30

def commit
  @commit
end

#nameObject (readonly)

Returns the value of attribute name.



29
30
31
# File 'lib/grit/ref.rb', line 29

def name
  @name
end

Class Method Details

.find_all(repo, options = {}) ⇒ Object

Find all Refs

+repo+ is the Repo
+options+ is a Hash of options

Returns Grit::Ref[] (baked)



12
13
14
15
16
17
18
19
# File 'lib/grit/ref.rb', line 12

def find_all(repo, options = {})
  refs = repo.git.refs(options, prefix)
  refs.split("\n").map do |ref|
    name, id = *ref.split(' ')
    commit = Commit.create(repo, :id => id)
    self.new(name, commit)
  end
end

Instance Method Details

#inspectObject

Pretty object inspection



43
44
45
# File 'lib/grit/ref.rb', line 43

def inspect
  %Q{#<#{self.class.name} "#{@name}">}
end