Class: JavaParse::JavaFiles

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/javaparse/java_files.rb

Instance Method Summary collapse

Constructor Details

#initialize(*directories) ⇒ JavaFiles

Returns a new instance of JavaFiles.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/javaparse/java_files.rb', line 7

def initialize(*directories)
  @java_units = []
  paths = directories.map { |directory|
    Dir.glob("#{directory}/**/*.java")
  }.flatten
  paths.uniq!
  paths.each { |path| 
        begin
          @java_units.push(JavaUnit.new(path))
        rescue 
          nil
        end
  }
end

Instance Method Details

#count(type = :files) ⇒ Object



26
27
28
29
30
# File 'lib/javaparse/java_files.rb', line 26

def count(type = :files)
  return @java_units.inject(0) { |sum, java_unit| sum + java_unit.send(type)} if [:bloc, :cloc, :loc, :all_lines].include? type.to_sym
  return @java_units.size if type == :files
  raise "Do not know how to count type #{type}"
end

#eachObject



22
23
24
# File 'lib/javaparse/java_files.rb', line 22

def each
  @java_units.each { |unit| yield unit }
end