Class: Gitlab::Git::DiffStatsCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Utils::StrongMemoize
Defined in:
lib/gitlab/git/diff_stats_collection.rb

Instance Method Summary collapse

Methods included from Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(diff_stats) ⇒ DiffStatsCollection

Returns a new instance of DiffStatsCollection.


9
10
11
# File 'lib/gitlab/git/diff_stats_collection.rb', line 9

def initialize(diff_stats)
  @collection = diff_stats
end

Instance Method Details

#each(&block) ⇒ Object


13
14
15
# File 'lib/gitlab/git/diff_stats_collection.rb', line 13

def each(&block)
  @collection.each(&block)
end

#find_by_path(path) ⇒ Object


17
18
19
# File 'lib/gitlab/git/diff_stats_collection.rb', line 17

def find_by_path(path)
  indexed_by_path[path]
end

#pathsObject


21
22
23
# File 'lib/gitlab/git/diff_stats_collection.rb', line 21

def paths
  @collection.map(&:path)
end

#real_sizeObject


25
26
27
28
29
30
31
32
# File 'lib/gitlab/git/diff_stats_collection.rb', line 25

def real_size
  max_files = ::Commit.max_diff_options[:max_files]
  if paths.size > max_files
    "#{max_files}+"
  else
    paths.size.to_s
  end
end