Class: Git::Log::Result
Overview
An immutable collection of commits returned by Git::Log#execute
This object is an Enumerable that contains Git::Object::Commit objects. It provides methods to access the commit data without executing any further git commands.
Instance Method Summary collapse
-
#[](index) ⇒ Git::Object::Commit?
The commit at the given index.
-
#each {|Git::Object::Commit| ... }
Iterates over each commit in the result set.
-
#first ⇒ Git::Object::Commit?
The first commit in the result set.
-
#initialize(commits) ⇒ Result
constructor
A new instance of Result.
-
#last ⇒ Git::Object::Commit?
The last commit in the result set.
-
#size ⇒ Integer
The number of commits in the result set.
-
#to_s ⇒ String
A string representation of the log.
Constructor Details
#initialize(commits) ⇒ Result
Returns a new instance of Result.
41 42 43 |
# File 'lib/git/log.rb', line 41 def initialize(commits) @commits = commits end |
Instance Method Details
#[](index) ⇒ Git::Object::Commit?
Returns the commit at the given index.
69 70 71 |
# File 'lib/git/log.rb', line 69 def [](index) @commits[index] end |
#each {|Git::Object::Commit| ... }
Iterates over each commit in the result set
53 54 55 |
# File 'lib/git/log.rb', line 53 def each(&block) @commits.each(&block) end |
#first ⇒ Git::Object::Commit?
Returns the first commit in the result set.
58 59 60 |
# File 'lib/git/log.rb', line 58 def first @commits.first end |
#last ⇒ Git::Object::Commit?
Returns the last commit in the result set.
63 64 65 |
# File 'lib/git/log.rb', line 63 def last @commits.last end |
#size ⇒ Integer
Returns the number of commits in the result set.
46 47 48 |
# File 'lib/git/log.rb', line 46 def size @commits.size end |
#to_s ⇒ String
Returns a string representation of the log.
74 75 76 |
# File 'lib/git/log.rb', line 74 def to_s map { |c| c.to_s }.join("\n") end |