Class: Gitrb::User
- Inherits:
-
Object
- Object
- Gitrb::User
- Defined in:
- lib/gitrb/user.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#name ⇒ Object
readonly
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.
6 7 8 9 10 |
# File 'lib/gitrb/user.rb', line 6 def initialize(name, email, date = Time.now) @name = name @email = email @date = date end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
4 5 6 |
# File 'lib/gitrb/user.rb', line 4 def date @date end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
4 5 6 |
# File 'lib/gitrb/user.rb', line 4 def email @email end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/gitrb/user.rb', line 4 def name @name end |
Class Method Details
.parse(user) ⇒ Object
17 18 19 20 21 |
# File 'lib/gitrb/user.rb', line 17 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
12 13 14 15 |
# File 'lib/gitrb/user.rb', line 12 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 |