Class: Gitrb::User

Inherits:
Struct
  • 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.



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

def initialize(name, email, date = Time.now)
  super
end

Instance Attribute Details

#dateObject

Returns the value of attribute date

Returns:

  • (Object)

    the current value of date



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

def date
  @date
end

#emailObject

Returns the value of attribute email

Returns:

  • (Object)

    the current value of email



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

def email
  @email
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of 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

#dumpObject



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