Class: Git::Log::Result

Inherits:
Data
  • Object
show all
Includes:
Enumerable
Defined in:
lib/git/log.rb

Overview

An immutable, Enumerable collection of Git::Object::Commit objects. Returned by Git::Log#execute.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commitsObject (readonly)

Returns the value of attribute commits

Returns:

  • (Object)

    the current value of commits



30
31
32
# File 'lib/git/log.rb', line 30

def commits
  @commits
end

Instance Method Details

#[](index) ⇒ Git::Object::Commit, ...

Returns a commit by index or a slice of commits by range

Parameters:

  • index (Integer, Range)

    the commit index or range to retrieve

Returns:



68
# File 'lib/git/log.rb', line 68

def [](index) = commits[index]

#eachEnumerator<Git::Object::Commit> #each {|commit| ... } ⇒ Array<Git::Object::Commit>

Iterates over each commit in query order

Overloads:

  • #eachEnumerator<Git::Object::Commit>

    Returns an enumerator over commits.

    Examples:

    Get an enumerator

    results.each.map(&:sha)

    Returns:

  • #each {|commit| ... } ⇒ Array<Git::Object::Commit>

    Returns the commit array.

    Examples:

    Iterate with a block

    results.each { |commit| puts commit.sha }

    Yields:

    • (commit)

      each commit from the result

    Yield Parameters:

    Yield Returns:

    • (void)

    Returns:



53
# File 'lib/git/log.rb', line 53

def each(&block) = commits.each(&block)

#lastGit::Object::Commit?

Returns the last commit in the result

Returns:



59
# File 'lib/git/log.rb', line 59

def last = commits.last

#sizeInteger

Returns the number of commits in the result

Returns:

  • (Integer)

    the commit count



80
# File 'lib/git/log.rb', line 80

def size = commits.size

#to_sString

Returns the commits joined with newlines

Returns:

  • (String)

    newline-separated commits



74
# File 'lib/git/log.rb', line 74

def to_s = commits.join("\n")