Class: SourceComponent
- Inherits:
-
Object
- Object
- SourceComponent
- Defined in:
- lib/cpp_dependency_graph/source_component.rb
Instance Method Summary collapse
- #includes ⇒ Object
-
#initialize(path) ⇒ SourceComponent
constructor
A new instance of SourceComponent.
- #loc ⇒ Object
- #name ⇒ Object
- #path ⇒ Object
- #source_files ⇒ Object
Constructor Details
#initialize(path) ⇒ SourceComponent
Returns a new instance of SourceComponent.
6 7 8 |
# File 'lib/cpp_dependency_graph/source_component.rb', line 6 def initialize(path) @path = path end |
Instance Method Details
#includes ⇒ Object
22 23 24 |
# File 'lib/cpp_dependency_graph/source_component.rb', line 22 def includes @includes ||= source_files.flat_map(&:includes).uniq.map { |include| File.basename(include) } end |
#loc ⇒ Object
26 27 28 |
# File 'lib/cpp_dependency_graph/source_component.rb', line 26 def loc @loc ||= source_files.inject(0) { |total_loc, file| total_loc + file.loc } end |
#name ⇒ Object
14 15 16 |
# File 'lib/cpp_dependency_graph/source_component.rb', line 14 def name @name ||= File.basename(@path) end |
#path ⇒ Object
10 11 12 |
# File 'lib/cpp_dependency_graph/source_component.rb', line 10 def path @path end |
#source_files ⇒ Object
18 19 20 |
# File 'lib/cpp_dependency_graph/source_component.rb', line 18 def source_files @source_files ||= parse_source_files('.{h,hpp,hxx,c,cpp,cxx,cc}') end |