#!/usr/local/bin/ruby class HexPipe HEXDATA = "~/hex-data" HEXCMD = "hex" PS = "> " def initialize Dir::chdir(File::expand_path(HEXDATA)) @p = IO::popen(HEXCMD, 'w+') gets end def gets s = "" loop do ps = @p.read(PS.length) return s if ps == PS s+= ps s+= @p.gets.chomp + " " end end def puts(s) @p.puts(s) @p.read(PS.length) @p.puts end def destroy @p.close end end