Class: Neovim::Connection Private
- Inherits:
-
Object
- Object
- Neovim::Connection
- Includes:
- Logging
- Defined in:
- lib/neovim/connection.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary
Constants included from Logging
Class Method Summary collapse
- .child(_argv) ⇒ Object private
- .stdio ⇒ Object private
- .tcp(host, port) ⇒ Object private
- .unix(path) ⇒ Object private
Instance Method Summary collapse
- #close ⇒ Object private
-
#initialize(rd, wr) ⇒ Connection
constructor
private
A new instance of Connection.
- #read ⇒ Object private
- #register_type(id, &block) ⇒ Object private
- #write(object) ⇒ Object private
Methods included from Logging
Constructor Details
#initialize(rd, wr) ⇒ Connection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Connection.
34 35 36 37 38 39 40 |
# File 'lib/neovim/connection.rb', line 34 def initialize(rd, wr) @rd, @wr = [rd, wr].each { |io| io.binmode.sync = true } @unpacker = MessagePack::Unpacker.new(@rd) @packer = MessagePack::Packer.new(@wr) @running = false end |
Class Method Details
.child(_argv) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 25 26 27 28 |
# File 'lib/neovim/connection.rb', line 20 def self.child(_argv) argv = _argv.include?("--embed") ? _argv : _argv + ["--embed"] io = ::IO.popen(argv, "rb+").tap do |_io| Process.detach(_io.pid) end new(io, io) end |
.stdio ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 |
# File 'lib/neovim/connection.rb', line 30 def self.stdio new(STDIN, STDOUT) end |
.tcp(host, port) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 13 |
# File 'lib/neovim/connection.rb', line 10 def self.tcp(host, port) socket = Socket.tcp(host, port) new(socket, socket) end |
.unix(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 18 |
# File 'lib/neovim/connection.rb', line 15 def self.unix(path) socket = Socket.unix(path) new(socket, socket) end |
Instance Method Details
#close ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
60 61 62 63 64 65 66 67 |
# File 'lib/neovim/connection.rb', line 60 def close [@rd, @wr].each do |io| begin io.close rescue ::IOError end end end |
#read ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 50 51 |
# File 'lib/neovim/connection.rb', line 47 def read @unpacker.read.tap do |object| log(:debug) { {object: object} } end end |
#register_type(id, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
53 54 55 56 57 58 |
# File 'lib/neovim/connection.rb', line 53 def register_type(id, &block) @unpacker.register_type(id) do |data| index = MessagePack.unpack(data) block.call(index) end end |
#write(object) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 45 |
# File 'lib/neovim/connection.rb', line 42 def write(object) log(:debug) { {object: object} } @packer.write(object).flush end |