Class: Amun::MajorModes::IRB
- Includes:
- Behaviours::Emacs
- Defined in:
- lib/amun/major_modes/irb.rb
Overview
mode that executes the last line in the current environment and print the output
Instance Attribute Summary
Attributes inherited from Object
Instance Method Summary collapse
- #execute_last_line ⇒ Object
-
#initialize(buffer) ⇒ IRB
constructor
A new instance of IRB.
Methods included from Behaviours::Emacs
Methods included from Behaviours::Insertion
#insert_char, #insertion_keymap_initialize
Methods included from Behaviours::Erasing
#backward_delete_char, #backward_kill_word, #delete_char, #erasing_keymap_initialize, #forward_delete_char, #kill_line, #kill_word
Methods included from Behaviours::Movement
#backward_char, #beginning_of_line, #end_of_line, #forward_char, #movement_keymap_initialize, #next_line, #previous_line
Constructor Details
#initialize(buffer) ⇒ IRB
Returns a new instance of IRB.
12 13 14 15 16 17 18 19 |
# File 'lib/amun/major_modes/irb.rb', line 12 def initialize(buffer) super() self.buffer = buffer emacs_behaviour_initialize bind "\n", self, :execute_last_line read_io if buffer.empty? end |
Instance Method Details
#execute_last_line ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/amun/major_modes/irb.rb', line 21 def execute_last_line(*) last_line = buffer.lines.last result = eval(last_line) buffer << "\n#{result}" rescue StandardError, SyntaxError => error buffer << "\n#{error.inspect}\n#{error.backtrace}" ensure buffer.point = buffer.length end |