Class: Grit::GitRuby::UserInfo
- Inherits:
-
Object
- Object
- Grit::GitRuby::UserInfo
- Defined in:
- lib/grit/git-ruby/git_object.rb
Overview
class for author/committer/tagger lines
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#email ⇒ Object
Returns the value of attribute email.
-
#name ⇒ Object
Returns the value of attribute name.
-
#offset ⇒ Object
Returns the value of attribute offset.
Instance Method Summary collapse
-
#initialize(str) ⇒ UserInfo
constructor
A new instance of UserInfo.
- #to_s ⇒ Object
Constructor Details
#initialize(str) ⇒ UserInfo
Returns a new instance of UserInfo.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/grit/git-ruby/git_object.rb', line 23 def initialize(str) @email = '' @date = Time.now @offset = 0 m = /^(.*?) <(.*)> (\d+) ([+-])0*(\d+?)$/.match(str) if !m case str when /<.+>/ m, @name, @email = *str.match(/(.*) <(.+?)>/) else @name = str end else @name = m[1] @email = m[2] @date = Time.at(Integer(m[3])) @offset = (m[4] == "-" ? -1 : 1)*Integer(m[5]) end end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
21 22 23 |
# File 'lib/grit/git-ruby/git_object.rb', line 21 def date @date end |
#email ⇒ Object
Returns the value of attribute email.
21 22 23 |
# File 'lib/grit/git-ruby/git_object.rb', line 21 def email @email end |
#name ⇒ Object
Returns the value of attribute name.
21 22 23 |
# File 'lib/grit/git-ruby/git_object.rb', line 21 def name @name end |
#offset ⇒ Object
Returns the value of attribute offset.
21 22 23 |
# File 'lib/grit/git-ruby/git_object.rb', line 21 def offset @offset end |
Instance Method Details
#to_s ⇒ Object
44 45 46 |
# File 'lib/grit/git-ruby/git_object.rb', line 44 def to_s "%s <%s> %s %+05d" % [@name, @email, @date.to_i, @offset] end |