Class: CodeStats::FileSet

Inherits:
Object
  • Object
show all
Defined in:
lib/code_stats/file_set.rb

Constant Summary collapse

AVAILIABLE_OPTIONS =
[:only, :except]

Instance Method Summary collapse

Constructor Details

#initializeFileSet

Returns a new instance of FileSet.


2
3
4
# File 'lib/code_stats/file_set.rb', line 2

def initialize
  @lines_count_by_language, @characters_count_by_language = Hash.new(0), Hash.new(0)
end

Instance Method Details

#add(script) ⇒ Object


26
27
28
29
# File 'lib/code_stats/file_set.rb', line 26

def add script
  @lines_count_by_language[script.class.alias.to_sym] += script.lines_count
  @characters_count_by_language[script.class.alias.to_sym] += script.characters_count
end

#characters_count(options = {}) ⇒ Object


12
13
14
15
16
# File 'lib/code_stats/file_set.rb', line 12

def characters_count options = {}
  total_count = 0
  characters_count_by_language(options).each{|lang, count| total_count += count}
  total_count
end

#characters_count_by_language(options = {}) ⇒ Object


22
23
24
# File 'lib/code_stats/file_set.rb', line 22

def characters_count_by_language options = {}
  filter_by_lang(@characters_count_by_language, options)
end

#lines_count(options = {}) ⇒ Object


6
7
8
9
10
# File 'lib/code_stats/file_set.rb', line 6

def lines_count options = {}
  total_count = 0
  lines_count_by_language(options).each{|lang, count| total_count += count}
  total_count
end

#lines_count_by_language(options = {}) ⇒ Object


18
19
20
# File 'lib/code_stats/file_set.rb', line 18

def lines_count_by_language options = {}
  filter_by_lang(@lines_count_by_language, options)
end