Class: Grit::Actor
- Inherits:
-
Object
- Object
- Grit::Actor
- Defined in:
- lib/grit/actor.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#name ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.from_string(str) ⇒ Object
Create an Actor from a string.
Instance Method Summary collapse
-
#initialize(name, email) ⇒ Actor
constructor
A new instance of Actor.
-
#inspect ⇒ Object
Pretty object inspection.
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
#email ⇒ Object (readonly)
Returns the value of attribute email.
5 6 7 |
# File 'lib/grit/actor.rb', line 5 def email @email end |
#name ⇒ Object (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
20 21 22 23 24 25 26 27 28 |
# File 'lib/grit/actor.rb', line 20 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
#inspect ⇒ Object
Pretty object inspection
31 32 33 |
# File 'lib/grit/actor.rb', line 31 def inspect %Q{#<Grit::Actor "#{@name} <#{@email}>">} end |