Class: Codescout::SourceFile
- Inherits:
-
Object
- Object
- Codescout::SourceFile
- Defined in:
- lib/codescout/source_file.rb
Defined Under Namespace
Classes: ObjectMethod
Instance Method Summary collapse
-
#initialize(code) ⇒ SourceFile
constructor
A new instance of SourceFile.
- #method_lines(method_name) ⇒ Object
- #method_source(method_name) ⇒ Object
Constructor Details
#initialize(code) ⇒ SourceFile
Returns a new instance of SourceFile.
16 17 18 |
# File 'lib/codescout/source_file.rb', line 16 def initialize(code) @parser = Parser::CurrentRuby.parse(code) end |
Instance Method Details
#method_lines(method_name) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/codescout/source_file.rb', line 30 def method_lines(method_name) @method_lines = nil recursive_search_ast(@parser, method_name) do |exp| @method_lines = exp.begin.line, exp.end.line end @method_lines end |
#method_source(method_name) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/codescout/source_file.rb', line 20 def method_source(method_name) @method_source = nil recursive_search_ast(@parser, method_name) do |exp| @method_source = ObjectMethod.new(exp) end @method_source end |