Module: LiveAST::IRBSpy
- Defined in:
- lib/live_ast/irb_spy.rb
Class Attribute Summary collapse
-
.history ⇒ Object
writeonly
Sets the attribute history.
Class Method Summary collapse
Class Attribute Details
.history=(value) ⇒ Object (writeonly)
Sets the attribute history
8 9 10 |
# File 'lib/live_ast/irb_spy.rb', line 8 def history=(value) @history = value end |
Class Method Details
.can_parse(code) ⇒ Object
18 19 20 21 22 |
# File 'lib/live_ast/irb_spy.rb', line 18 def can_parse(code) LiveAST.parser.new.parse(code) rescue StandardError false end |
.checked_history ⇒ Object
24 25 26 27 28 29 |
# File 'lib/live_ast/irb_spy.rb', line 24 def checked_history return @history if @history raise NotImplementedError, "LiveAST cannot access history for this IRB input method" end |
.code_at(line) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/live_ast/irb_spy.rb', line 10 def code_at(line) code = +"" checked_history[line..].each do |code_line| code += "#{code_line}\n" return code if can_parse code end end |