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
7 8 9 |
# File 'lib/live_ast/irb_spy.rb', line 7 def history=(value) @history = value end |
Class Method Details
.can_parse(code) ⇒ Object
17 18 19 20 21 |
# File 'lib/live_ast/irb_spy.rb', line 17 def can_parse(code) LiveAST.parser.new.parse(code) rescue StandardError false end |
.checked_history ⇒ Object
23 24 25 26 27 |
# File 'lib/live_ast/irb_spy.rb', line 23 def checked_history return @history if @history raise NotImplementedError, "LiveAST cannot access history for this IRB input method" end |
.code_at(line) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/live_ast/irb_spy.rb', line 9 def code_at(line) code = "" checked_history[line..-1].each do |code_line| code << code_line << "\n" return code if can_parse code end end |