class PmdTester::CollectionByFile
A collection of things, grouped by file.
(Note: this replaces PmdErrors and PmdViolations)
Public Class Methods
new()
click to toggle source
# File lib/pmdtester/collection_by_file.rb, line 8 def initialize # a hash of filename -> [list of items] @hash = Hash.new([]) @total = 0 end
Public Instance Methods
[](fname)
click to toggle source
# File lib/pmdtester/collection_by_file.rb, line 47 def [](fname) @hash[fname] end
add_all(filename, values)
click to toggle source
# File lib/pmdtester/collection_by_file.rb, line 14 def add_all(filename, values) return if values.empty? if @hash.key?(filename) @hash[filename].concat(values) else @hash[filename] = values end @total += values.size end
all_files()
click to toggle source
# File lib/pmdtester/collection_by_file.rb, line 29 def all_files @hash.keys end
all_values()
click to toggle source
# File lib/pmdtester/collection_by_file.rb, line 37 def all_values @hash.values.flatten end
each_value(&block)
click to toggle source
# File lib/pmdtester/collection_by_file.rb, line 41 def each_value(&block) @hash.each_value do |vs| vs.each(&block) end end
num_files()
click to toggle source
# File lib/pmdtester/collection_by_file.rb, line 33 def num_files @hash.size end
to_h()
click to toggle source
# File lib/pmdtester/collection_by_file.rb, line 51 def to_h @hash end
total_size()
click to toggle source
# File lib/pmdtester/collection_by_file.rb, line 25 def total_size @total end