Class: Gitrb::User

Inherits:
Object
  • Object
show all
Defined in:
lib/gitrb/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#dateObject (readonly)

Returns the value of attribute date


4
5
6
# File 'lib/gitrb/user.rb', line 4

def date
  @date
end

#emailObject (readonly)

Returns the value of attribute email


4
5
6
# File 'lib/gitrb/user.rb', line 4

def email
  @email
end

#nameObject (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

#dumpObject


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.abs / 60, off % 60]
end