Class: ClassSource::Scanner

Inherits:
Object
  • Object
show all
Defined in:
lib/class_source/scanner.rb

Overview

A helper class for scanning files looking for potential class declarations

Instance Method Summary collapse

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

#locationsArray

Returns An array of [file_name, line_number] tuples where the classes name was detected.

Returns:

  • (Array)

    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