class Nydp::ReadlineReader

Public Class Methods

new(stream, prompt) click to toggle source
# File lib/nydp/runner.rb, line 54
def initialize stream, prompt
  @prompt = prompt
  setup_readline_history
end

Public Instance Methods

nextline() click to toggle source

with thanks to ruby-doc.org/stdlib-1.9.3/libdoc/readline/rdoc/Readline.html and bogojoker.com/readline/

# File lib/nydp/runner.rb, line 61
def nextline
  line = Readline.readline(@prompt, true)
  return nil if line.nil?
  if line =~ /^\s*$/ or Readline::HISTORY.to_a[-2] == line
    Readline::HISTORY.pop
  end
  line
end