Class: Laerad::FileAnalyzer
- Inherits:
-
Object
- Object
- Laerad::FileAnalyzer
- Defined in:
- lib/laerad/file_analyzer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #analyze ⇒ Object
-
#initialize(path, options = {}) ⇒ FileAnalyzer
constructor
A new instance of FileAnalyzer.
Constructor Details
#initialize(path, options = {}) ⇒ FileAnalyzer
Returns a new instance of FileAnalyzer.
11 12 13 14 15 16 17 |
# File 'lib/laerad/file_analyzer.rb', line 11 def initialize(path, = {}) @path = path @source = File.read(path) @scope_stack = [Scope.new] @result = Result.new(file: path) = end |
Class Method Details
.analyze(path, options = {}) ⇒ Object
7 8 9 |
# File 'lib/laerad/file_analyzer.rb', line 7 def self.analyze(path, = {}) new(path, ).analyze end |
Instance Method Details
#analyze ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/laerad/file_analyzer.rb', line 19 def analyze ast = SyntaxTree.parse(@source) visit(ast) finalize_scope(@scope_stack.last) @result rescue SyntaxTree::Parser::ParseError @result end |