Class: Hubtime::Commit
- Inherits:
-
Object
- Object
- Hubtime::Commit
- Defined in:
- lib/hubtime/commit.rb
Instance Attribute Summary collapse
-
#additions ⇒ Object
readonly
Returns the value of attribute additions.
-
#committer ⇒ Object
readonly
Returns the value of attribute committer.
-
#deletions ⇒ Object
readonly
Returns the value of attribute deletions.
-
#repo_name ⇒ Object
readonly
Returns the value of attribute repo_name.
-
#sha ⇒ Object
readonly
Returns the value of attribute sha.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #count ⇒ Object
- #impact ⇒ Object
-
#initialize(hash, repo_name = nil, committer = nil) ⇒ Commit
constructor
A new instance of Commit.
- #to_s ⇒ Object
Constructor Details
#initialize(hash, repo_name = nil, committer = nil) ⇒ Commit
Returns a new instance of Commit.
6 7 8 9 10 11 12 13 |
# File 'lib/hubtime/commit.rb', line 6 def initialize(hash, repo_name = nil, committer = nil) @repo_name = repo_name # or figure it out @sha = hash["sha"] @additions = hash["stats"]["additions"].to_i @deletions = hash["stats"]["deletions"].to_i @committer = committer # or figure it out @time = parse_time(hash) end |
Instance Attribute Details
#additions ⇒ Object (readonly)
Returns the value of attribute additions.
5 6 7 |
# File 'lib/hubtime/commit.rb', line 5 def additions @additions end |
#committer ⇒ Object (readonly)
Returns the value of attribute committer.
5 6 7 |
# File 'lib/hubtime/commit.rb', line 5 def committer @committer end |
#deletions ⇒ Object (readonly)
Returns the value of attribute deletions.
5 6 7 |
# File 'lib/hubtime/commit.rb', line 5 def deletions @deletions end |
#repo_name ⇒ Object (readonly)
Returns the value of attribute repo_name.
5 6 7 |
# File 'lib/hubtime/commit.rb', line 5 def repo_name @repo_name end |
#sha ⇒ Object (readonly)
Returns the value of attribute sha.
5 6 7 |
# File 'lib/hubtime/commit.rb', line 5 def sha @sha end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
5 6 7 |
# File 'lib/hubtime/commit.rb', line 5 def time @time end |
Instance Method Details
#count ⇒ Object
19 20 21 22 |
# File 'lib/hubtime/commit.rb', line 19 def count return 0 if impact <= 0 1 end |
#impact ⇒ Object
24 25 26 |
# File 'lib/hubtime/commit.rb', line 24 def impact additions + deletions end |
#to_s ⇒ Object
15 16 17 |
# File 'lib/hubtime/commit.rb', line 15 def to_s "#{time.strftime('%F')} commit: #{repo_name} : #{sha} by #{committer} with #{additions} additions and #{deletions} deletions}" end |