Class: MultiGit::Handle

Inherits:
Struct
  • Object
show all
Defined in:
lib/multi_git/handle.rb

Overview

Encapsulates name + email. Mostly used for commits.

Constant Summary collapse

DEFAULT =
parse("MultiGit <[email protected]>")

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#emailObject

Returns the value of attribute email

Returns:

  • (Object)

    the current value of email



3
4
5
# File 'lib/multi_git/handle.rb', line 3

def email
  @email
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



3
4
5
# File 'lib/multi_git/handle.rb', line 3

def name
  @name
end

Class Method Details

.parse(string) ⇒ Handle

Parses a handle from a string

Currently two formats are recognized. Either just a mail address (e.g. ‘[email protected]’) or user + mail address in brackets ( e.g. ‘User <[email protected]>’ ).

Examples:

MultiGit::Handle.parse('[email protected]') #=> be_a MultiGit::Handle

Parameters:

  • string (String)

    a string containing a handle.

Returns:



22
23
24
25
26
27
28
# File 'lib/multi_git/handle.rb', line 22

def self.parse(string)
  case(string)
  when EMAIL then return new(string, string)
  when NAME_WITH_EMAIL then return new($1,$2)
  else raise ArgumentError, "Unknown handle format: #{string}. Please use either '[email protected]' or 'User <[email protected]>'"
  end
end