Create an Actor from a string.
str - The String in this format: 'John Doe <jdoe@example.com>'
Returns Git::Actor.
# File lib/grit/actor.rb, line 18 def self.from_string(str) case str when /<.+>/ m, name, email = *str.match(/(.*) <(.+?)>/) return self.new(name, email) else return self.new(str, nil) end end
Pretty object inspection
# File lib/grit/actor.rb, line 47 def inspect %{#<Grit::Actor "#{@name} <#{@email}>">} end
Outputs an actor string for Git commits.
actor = Actor.new('bob', 'bob@email.com') actor.output(time) # => "bob <bob@email.com> UNIX_TIME +0700"
time - The Time the commit was authored or committed.
Returns a String.
# File lib/grit/actor.rb, line 36 def output(time) offset = time.utc_offset / 60 "%s <%s> %d %+.2d%.2d" % [ @name, @email || "null", time.to_i, offset / 60, offset.abs % 60] end
Generated with the Darkfish Rdoc Generator 2.