class GitDiff::StatsCalculator
Attributes
collector[R]
Public Class Methods
new(collector)
click to toggle source
# File lib/git_diff/stats_calculator.rb, line 7 def initialize(collector) @collector = collector end
Public Instance Methods
total()
click to toggle source
# File lib/git_diff/stats_calculator.rb, line 11 def total GitDiff::Stats.new( number_of_lines: calculate_total(:number_of_lines), number_of_additions: calculate_total(:number_of_additions), number_of_deletions: calculate_total(:number_of_deletions) ) end
Private Instance Methods
calculate_total(type)
click to toggle source
# File lib/git_diff/stats_calculator.rb, line 21 def calculate_total(type) collect_stat(type).inject(:+) end
collect_stat(type)
click to toggle source
# File lib/git_diff/stats_calculator.rb, line 25 def collect_stat(type) stats_collection.map { |stats| stats.public_send(type) }.flatten end
stats_collection()
click to toggle source
# File lib/git_diff/stats_calculator.rb, line 29 def stats_collection Array(collector.collect) end