Class: Hubtime::Commit

Inherits:
Object
  • Object
show all
Defined in:
lib/hubtime/commit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#additionsObject (readonly)

Returns the value of attribute additions.



5
6
7
# File 'lib/hubtime/commit.rb', line 5

def additions
  @additions
end

#committerObject (readonly)

Returns the value of attribute committer.



5
6
7
# File 'lib/hubtime/commit.rb', line 5

def committer
  @committer
end

#deletionsObject (readonly)

Returns the value of attribute deletions.



5
6
7
# File 'lib/hubtime/commit.rb', line 5

def deletions
  @deletions
end

#repo_nameObject (readonly)

Returns the value of attribute repo_name.



5
6
7
# File 'lib/hubtime/commit.rb', line 5

def repo_name
  @repo_name
end

#shaObject (readonly)

Returns the value of attribute sha.



5
6
7
# File 'lib/hubtime/commit.rb', line 5

def sha
  @sha
end

#timeObject (readonly)

Returns the value of attribute time.



5
6
7
# File 'lib/hubtime/commit.rb', line 5

def time
  @time
end

Instance Method Details

#countObject



19
20
21
22
# File 'lib/hubtime/commit.rb', line 19

def count
  return 0 if impact <= 0
  1
end

#impactObject



24
25
26
# File 'lib/hubtime/commit.rb', line 24

def impact
  additions + deletions
end

#to_sObject



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