Class: RemoteRuby::SourceExtractor
- Inherits:
-
Object
- Object
- RemoteRuby::SourceExtractor
- Defined in:
- lib/remote_ruby/source_extractor.rb
Overview
Receives a block and extracts Ruby code (as a string) with this block’s source
Instance Method Summary collapse
Instance Method Details
#extract(&block) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/remote_ruby/source_extractor.rb', line 21 def extract(&block) ast = Parser::CurrentRuby.parse(block.source) block_node = find_block(ast) return '' unless block_node _, body = parse(block_node) Unparser.unparse(body) end |