Class: Grit::GitRuby::UserInfo
- Inherits:
-
Object
- Object
- Grit::GitRuby::UserInfo
- Defined in:
- lib/grit/git-ruby/object.rb,
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 |
# File 'lib/grit/git-ruby/object.rb', line 23 def initialize(str) m = /^(.*?) <(.*)> (\d+) ([+-])0*(\d+?)$/.match(str) if !m raise RuntimeError, "invalid header '%s' in commit" % str end @name = m[1] @email = m[2] @date = Time.at(Integer(m[3])) @offset = (m[4] == "-" ? -1 : 1)*Integer(m[5]) end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
21 22 23 |
# File 'lib/grit/git-ruby/object.rb', line 21 def date @date end |
#email ⇒ Object
Returns the value of attribute email.
21 22 23 |
# File 'lib/grit/git-ruby/object.rb', line 21 def email @email end |
#name ⇒ Object
Returns the value of attribute name.
21 22 23 |
# File 'lib/grit/git-ruby/object.rb', line 21 def name @name end |
#offset ⇒ Object
Returns the value of attribute offset.
21 22 23 |
# File 'lib/grit/git-ruby/object.rb', line 21 def offset @offset end |
Instance Method Details
#to_s ⇒ Object
34 35 36 |
# File 'lib/grit/git-ruby/object.rb', line 34 def to_s "%s <%s> %s %+05d" % [@name, @email, @date.to_i, @offset] end |