Class: Git::Author

Inherits:
Object
  • Object
show all
Defined in:
lib/git/author.rb

Overview

An author in a Git commit

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(author_string)

Initializes a new Author object from a string

Examples:

Git::Author.new("John Doe <john.doe@example.com> 1627849923 +0200")

Parameters:

  • author_string (String)

    the author string



27
28
29
30
31
32
33
# File 'lib/git/author.rb', line 27

def initialize(author_string)
  return unless (m = /(.*?) <(.*?)> (\d+) (.*)/.match(author_string))

  @name = m[1]
  @email = m[2]
  @date = Time.at(m[3].to_i)
end

Instance Attribute Details

#dateTime?

Returns the date the change was authored (author date, not committer date).

Returns:

  • (Time, nil)

    the date the change was authored (author date, not committer date)



16
17
18
# File 'lib/git/author.rb', line 16

def date
  @date
end

#emailString?

Returns the author's email.

Returns:

  • (String, nil)

    the author's email



13
14
15
# File 'lib/git/author.rb', line 13

def email
  @email
end

#nameString?

Returns the author's name.

Returns:

  • (String, nil)

    the author's name



10
11
12
# File 'lib/git/author.rb', line 10

def name
  @name
end