Sha256: e689efe2c22ece6a4277d48de0b4da26edec664a5c52749d222f8eae8babecd9

Contents?: true

Size: 466 Bytes

Versions: 3

Compression:

Stored size: 466 Bytes

Contents

module Gitrb

  class User < Struct.new(:name, :email, :date)
    def initialize(name, email, date = Time.now)
      super
    end

    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

    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

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gitrb-0.1.1 lib/gitrb/user.rb
gitrb-0.1.0 lib/gitrb/user.rb
gitrb-0.0.9 lib/gitrb/user.rb