Class: Laplus::Source
- Inherits:
-
Object
- Object
- Laplus::Source
- Defined in:
- lib/laplus/source.rb
Constant Summary collapse
Instance Method Summary collapse
-
#initialize(path, reader = File, parser = Parser.new) ⇒ Source
constructor
A new instance of Source.
- #snip_code_at(line) ⇒ Object
Constructor Details
Instance Method Details
#snip_code_at(line) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/laplus/source.rb', line 15 def snip_code_at(line) beginning_index = line - 1 ending_index = (beginning_index..).find do |index| raise SnipTooManyLines if index - beginning_index > 100 code = lines[beginning_index..index].join parser.parse(code) end snip_line_in(beginning_index..ending_index) end |