Class: ClassSource::Scanner
- Inherits:
-
Object
- Object
- ClassSource::Scanner
- Defined in:
- lib/class_source/scanner.rb
Overview
A helper class for scanning files looking for potential class declarations
Instance Method Summary collapse
-
#initialize(klass, source_files) ⇒ Scanner
constructor
A new instance of Scanner.
-
#locations ⇒ Array
An array of [file_name, line_number] tuples where the classes name was detected.
Constructor Details
#initialize(klass, source_files) ⇒ Scanner
Returns a new instance of Scanner.
4 5 6 7 |
# File 'lib/class_source/scanner.rb', line 4 def initialize(klass, source_files) @source_files = source_files @klass = klass end |
Instance Method Details
#locations ⇒ Array
Returns An array of [file_name, line_number] tuples where the classes name was detected.
10 11 12 13 14 15 |
# File 'lib/class_source/scanner.rb', line 10 def locations return if @source_files.empty? @source_files.map do |file| [file, find_module_name(File.read(file))] end.select { |result| !result.last.nil? } end |