Class: LiveAST::Cache
- Inherits:
-
Object
- Object
- LiveAST::Cache
- Defined in:
- lib/live_ast/linker.rb
Instance Method Summary collapse
- #fetch_ast(line) ⇒ Object
-
#initialize(file, lineno) ⇒ Cache
constructor
A new instance of Cache.
Constructor Details
#initialize(file, lineno) ⇒ Cache
5 6 7 8 9 |
# File 'lib/live_ast/linker.rb', line 5 def initialize(file, lineno) @source = file @user_line = lineno @asts = nil end |
Instance Method Details
#fetch_ast(line) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/live_ast/linker.rb', line 11 def fetch_ast(line) @asts ||= LiveAST.parser.new.parse(@source).tap do @source = nil end @asts.fetch(line - @user_line + 1, nil) end |