Class: SourceFile

Inherits:
Object
  • Object
show all
Defined in:
lib/cpp_dependency_graph/source_file.rb

Overview

Source file and metadata

Instance Method Summary collapse

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

#basenameObject



9
10
11
# File 'lib/cpp_dependency_graph/source_file.rb', line 9

def basename
  @basename ||= File.basename(@path)
end

#basename_no_extensionObject



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

Returns:

  • (Boolean)


21
22
23
# File 'lib/cpp_dependency_graph/source_file.rb', line 21

def header?
  false # TODO: Implement check extension
end

#includesObject



29
30
31
# File 'lib/cpp_dependency_graph/source_file.rb', line 29

def includes
  @includes ||= all_includes
end

#locObject



33
34
35
# File 'lib/cpp_dependency_graph/source_file.rb', line 33

def loc
  @loc ||= file_contents.lines.count
end

#parent_componentObject



25
26
27
# File 'lib/cpp_dependency_graph/source_file.rb', line 25

def parent_component
  @parent_component ||= File.dirname(@path).split('/').last
end

#pathObject



17
18
19
# File 'lib/cpp_dependency_graph/source_file.rb', line 17

def path
  @path ||= File.absolute_path(@path)
end