Class: Gitrb::User
- Inherits:
-
Struct
- Object
- Struct
- Gitrb::User
- Defined in:
- lib/gitrb/user.rb
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.
Class Method Summary collapse
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(name, email, date = Time.now) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(name, email, date = Time.now) ⇒ User
Returns a new instance of User.
4 5 6 |
# File 'lib/gitrb/user.rb', line 4 def initialize(name, email, date = Time.now) super end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date
3 4 5 |
# File 'lib/gitrb/user.rb', line 3 def date @date end |
#email ⇒ Object
Returns the value of attribute email
3 4 5 |
# File 'lib/gitrb/user.rb', line 3 def email @email end |
#name ⇒ Object
Returns the value of attribute name
3 4 5 |
# File 'lib/gitrb/user.rb', line 3 def name @name end |
Class Method Details
.parse(user) ⇒ Object
13 14 15 16 17 |
# File 'lib/gitrb/user.rb', line 13 def self.parse(user) if match = user.match(/(.*)<(.*)> (\d+) ([+-]?\d+)/) new match[1].strip, match[2].strip, Time.at(match[3].to_i) end end |
Instance Method Details
#dump ⇒ Object
8 9 10 11 |
# File 'lib/gitrb/user.rb', line 8 def dump off = date.gmt_offset / 60 '%s <%s> %d %s%02d%02d' % [name, email, date.to_i, off < 0 ? '' : '+', off / 60, off % 60] end |