Sha256: 30d582f0265284c6ce54c27a170e078a1068ab71910d2be2e0c94228f55a8f76

Contents?: true

Size: 483 Bytes

Versions: 8

Compression:

Stored size: 483 Bytes

Contents

module Gitrb

  class User
    attr_accessor :name, :email, :date

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

    def dump
      "#{name} <#{email}> #{date.localtime.to_i} #{date.gmt_offset < 0 ? '-' : '+'}#{date.gmt_offset / 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

8 entries across 8 versions & 1 rubygems

Version Path
gitrb-0.0.8 lib/gitrb/user.rb
gitrb-0.0.7 lib/gitrb/user.rb
gitrb-0.0.6 lib/gitrb/user.rb
gitrb-0.0.5 lib/gitrb/user.rb
gitrb-0.0.4 lib/gitrb/user.rb
gitrb-0.0.3 lib/gitrb/user.rb
gitrb-0.0.2 lib/gitrb/user.rb
gitrb-0.0.1 lib/gitrb/user.rb