Class: Grit::Actor

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, email) ⇒ Actor

Returns a new instance of Actor.



7
8
9
10
# File 'lib/grit/actor.rb', line 7

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

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



5
6
7
# File 'lib/grit/actor.rb', line 5

def email
  @email
end

#nameObject (readonly) Also known as: to_s

Returns the value of attribute name.



4
5
6
# File 'lib/grit/actor.rb', line 4

def name
  @name
end

Class Method Details

.from_string(str) ⇒ Object

Create an Actor from a string.

+str+ is the string, which is expected to be in regular git format

Format

John Doe <[email protected]>

Returns Actor



25
26
27
28
29
30
31
32
33
# File 'lib/grit/actor.rb', line 25

def self.from_string(str)
  case str
    when /<.+>/
      m, name, email = *str.match(/(.*) <(.+?)>/)
      return self.new(name, email)
    else
      return self.new(str, nil)
  end
end

Instance Method Details

#inspectObject

Pretty object inspection



36
37
38
# File 'lib/grit/actor.rb', line 36

def inspect
  %Q{#<Grit::Actor "#{@name} <#{@email}>">}
end

#to_git_formatObject

Returns this actor in the git format, as taken by from_string



14
15
16
# File 'lib/grit/actor.rb', line 14

def to_git_format
  @email ? "#{@name} <#{@email}>" : @name
end