Class: SourceFile
- Inherits:
-
Object
- Object
- SourceFile
- Defined in:
- lib/cpp_dependency_graph/source_file.rb
Overview
Source file and metadata
Instance Method Summary collapse
- #basename ⇒ Object
- #basename_no_extension ⇒ Object
- #header? ⇒ Boolean
- #includes ⇒ Object
-
#initialize(file) ⇒ SourceFile
constructor
A new instance of SourceFile.
- #loc ⇒ Object
- #parent_component ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(file) ⇒ SourceFile
Returns a new instance of SourceFile.
5 6 7 |
# File 'lib/cpp_dependency_graph/source_file.rb', line 5 def initialize(file) @path = file end |
Instance Method Details
#basename ⇒ Object
9 10 11 |
# File 'lib/cpp_dependency_graph/source_file.rb', line 9 def basename @basename ||= File.basename(@path) end |
#basename_no_extension ⇒ Object
13 14 15 |
# File 'lib/cpp_dependency_graph/source_file.rb', line 13 def basename_no_extension @basename_no_extension ||= File.basename(@path, File.extname(@path)) end |
#header? ⇒ Boolean
21 22 23 |
# File 'lib/cpp_dependency_graph/source_file.rb', line 21 def header? false # TODO: Implement check extension end |
#includes ⇒ Object
29 30 31 |
# File 'lib/cpp_dependency_graph/source_file.rb', line 29 def includes @includes ||= all_includes end |
#loc ⇒ Object
33 34 35 |
# File 'lib/cpp_dependency_graph/source_file.rb', line 33 def loc @loc ||= file_contents.lines.count end |
#parent_component ⇒ Object
25 26 27 |
# File 'lib/cpp_dependency_graph/source_file.rb', line 25 def parent_component @parent_component ||= File.dirname(@path).split('/').last end |
#path ⇒ Object
17 18 19 |
# File 'lib/cpp_dependency_graph/source_file.rb', line 17 def path @path ||= File.absolute_path(@path) end |