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.
5 6 7 8 9 |
# File 'lib/gitrb/user.rb', line 5 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.
3 4 5 |
# File 'lib/gitrb/user.rb', line 3 def date @date end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
3 4 5 |
# File 'lib/gitrb/user.rb', line 3 def email @email end |
#name ⇒ Object (readonly)
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
16 17 18 19 20 |
# File 'lib/gitrb/user.rb', line 16 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
11 12 13 14 |
# File 'lib/gitrb/user.rb', line 11 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 |