Class: RLSL::Prism::SourceExtractor
- Inherits:
-
Object
- Object
- RLSL::Prism::SourceExtractor
show all
- Defined in:
- lib/rlsl/prism/source_extractor.rb,
lib/rlsl/prism/source_extractor/block_locator.rb
Defined Under Namespace
Classes: BlockLocator, SourceNotAvailable
Instance Method Summary
collapse
Constructor Details
#initialize(block_locator = BlockLocator.new) ⇒ SourceExtractor
Returns a new instance of SourceExtractor.
13
14
15
|
# File 'lib/rlsl/prism/source_extractor.rb', line 13
def initialize(block_locator = BlockLocator.new)
@block_locator = block_locator
end
|
Instance Method Details
17
18
19
|
# File 'lib/rlsl/prism/source_extractor.rb', line 17
def (block)
(block).to_source
end
|
28
29
30
|
# File 'lib/rlsl/prism/source_extractor.rb', line 28
def (source)
source
end
|
21
22
23
24
25
26
|
# File 'lib/rlsl/prism/source_extractor.rb', line 21
def (block)
file, line_num = block.source_location
raise SourceNotAvailable, "Block source location not available" unless file && File.exist?(file)
@block_locator.(File.read(file), line_num)
end
|