class Neovim::Connection
@api private
Public Class Methods
child(argv)
click to toggle source
# File lib/neovim/connection.rb, line 20 def self.child(argv) argv = argv.include?("--embed") ? argv : argv + ["--embed"] io = ::IO.popen(argv, "rb+") Process.detach(io.pid) new(io, io) end
new(rd, wr)
click to toggle source
# File lib/neovim/connection.rb, line 33 def initialize(rd, wr) @rd, @wr = [rd, wr].each { |io| io.binmode.sync = true } @unpacker = MessagePack::Unpacker.new(@rd) @packer = MessagePack::Packer.new(@wr) end
stdio()
click to toggle source
# File lib/neovim/connection.rb, line 29 def self.stdio new(STDIN, STDOUT) end
tcp(host, port)
click to toggle source
# File lib/neovim/connection.rb, line 10 def self.tcp(host, port) socket = Socket.tcp(host, port) new(socket, socket) end
unix(path)
click to toggle source
# File lib/neovim/connection.rb, line 15 def self.unix(path) socket = Socket.unix(path) new(socket, socket) end
Public Instance Methods
close()
click to toggle source
# File lib/neovim/connection.rb, line 64 def close [@rd, @wr].each do |io| begin io.close rescue ::IOError end end end
flush()
click to toggle source
# File lib/neovim/connection.rb, line 52 def flush @packer.flush self end
read()
click to toggle source
# File lib/neovim/connection.rb, line 46 def read @unpacker.read.tap do |object| log(:debug) { {object: object} } end end
register_type(id) { |index| ... }
click to toggle source
# File lib/neovim/connection.rb, line 57 def register_type(id) @unpacker.register_type(id) do |data| index = MessagePack.unpack(data) yield index end end
write(object)
click to toggle source
# File lib/neovim/connection.rb, line 40 def write(object) log(:debug) { {object: object} } @packer.write(object) self end