Class: Spoom::Git::Commit
- Inherits:
-
Object
- Object
- Spoom::Git::Commit
- Defined in:
- lib/spoom/context/git.rb
Instance Attribute Summary collapse
-
#sha ⇒ Object
readonly
: String.
-
#time ⇒ Object
readonly
: Time.
Class Method Summary collapse
-
.parse_line(string) ⇒ Object
Parse a line formatted as
%h %atinto aCommit: (String string) -> Commit?.
Instance Method Summary collapse
-
#initialize(sha:, time:) ⇒ Commit
constructor
: (sha: String, time: Time) -> void.
-
#timestamp ⇒ Object
: -> Integer.
Constructor Details
#initialize(sha:, time:) ⇒ Commit
: (sha: String, time: Time) -> void
28 29 30 31 |
# File 'lib/spoom/context/git.rb', line 28 def initialize(sha:, time:) @sha = sha @time = time end |
Instance Attribute Details
#sha ⇒ Object (readonly)
: String
22 23 24 |
# File 'lib/spoom/context/git.rb', line 22 def sha @sha end |
#time ⇒ Object (readonly)
: Time
25 26 27 |
# File 'lib/spoom/context/git.rb', line 25 def time @time end |
Class Method Details
.parse_line(string) ⇒ Object
Parse a line formatted as %h %at into a Commit
: (String string) -> Commit?
12 13 14 15 16 17 18 |
# File 'lib/spoom/context/git.rb', line 12 def parse_line(string) sha, epoch = string.split(" ", 2) return unless sha && epoch time = Time.strptime(epoch, "%s") Commit.new(sha: sha, time: time) end |
Instance Method Details
#timestamp ⇒ Object
: -> Integer
34 35 36 |
# File 'lib/spoom/context/git.rb', line 34 def time.to_i end |