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
- #flush ⇒ Object private
-
#initialize(rd, wr) ⇒ Connection
constructor
private
A new instance of Connection.
- #read ⇒ Object private
- #register_type(id) ⇒ 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.
33 34 35 36 37 38 39 |
# 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) @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 |
# 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 |
.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.
29 30 31 |
# File 'lib/neovim/connection.rb', line 29 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.
65 66 67 68 69 70 71 72 |
# File 'lib/neovim/connection.rb', line 65 def close [@rd, @wr].each do |io| begin io.close rescue ::IOError end end end |
#flush ⇒ 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 |
# File 'lib/neovim/connection.rb', line 53 def flush @packer.flush self 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) ⇒ 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.
58 59 60 61 62 63 |
# File 'lib/neovim/connection.rb', line 58 def register_type(id) @unpacker.register_type(id) do |data| index = MessagePack.unpack(data) yield 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.
41 42 43 44 45 |
# File 'lib/neovim/connection.rb', line 41 def write(object) log(:debug) { {object: object} } @packer.write(object) self end |