Class: WhatDyaReturn::Extractor
- Inherits:
-
Object
- Object
- WhatDyaReturn::Extractor
- Defined in:
- lib/what_dya_return/extractor.rb
Instance Method Summary collapse
-
#extract(source_code) ⇒ Array<String>
Extracts the return value candidates from ‘source_code`.
Instance Method Details
#extract(source_code) ⇒ Array<String>
Extracts the return value candidates from ‘source_code`
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/what_dya_return/extractor.rb', line 28 def extract(source_code) processed = AST::ProcessedSource.new(source_code, RUBY_VERSION.to_f) raise WhatDyaReturn::SyntaxError unless processed.valid_syntax? raise WhatDyaReturn::ArgumentError if processed.ast.type != :def Processor.new.process(processed.ast).map do |node| node.nil? ? 'nil' : Unparser.unparse(node) end.uniq end |