class Amun::MajorModes::IRB

mode that executes the last line in

the current environment and print the output

Attributes

buffer[RW]

Public Class Methods

new(buffer) click to toggle source
Calls superclass method
# 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

Public Instance Methods

execute_last_line(*) click to toggle source
# 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

Private Instance Methods

read_io() click to toggle source
# File lib/amun/major_modes/irb.rb, line 35
def read_io
  buffer << buffer.io.read
end