Class: Neovim::EventLoop Private
- Inherits:
-
Object
- Object
- Neovim::EventLoop
- Includes:
- Logging
- Defined in:
- lib/neovim/event_loop.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
-
#initialize(connection) ⇒ EventLoop
constructor
private
A new instance of EventLoop.
- #notify(method, *args) ⇒ Object private
- #register_types(api, session) ⇒ Object private
- #request(request_id, method, *args) ⇒ Object private
- #respond(request_id, return_value, error) ⇒ Object private
- #run(&callback) ⇒ Object private
- #shutdown ⇒ Object private
- #stop ⇒ Object private
Methods included from Logging
Constructor Details
#initialize(connection) ⇒ EventLoop
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 EventLoop.
26 27 28 29 30 |
# File 'lib/neovim/event_loop.rb', line 26 def initialize(connection) @running = false @shutdown = false @connection = connection 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.
18 19 20 |
# File 'lib/neovim/event_loop.rb', line 18 def self.child(argv) new Connection.child(argv) 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.
22 23 24 |
# File 'lib/neovim/event_loop.rb', line 22 def self.stdio new Connection.stdio 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 |
# File 'lib/neovim/event_loop.rb', line 10 def self.tcp(host, port) new Connection.tcp(host, port) 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.
14 15 16 |
# File 'lib/neovim/event_loop.rb', line 14 def self.unix(path) new Connection.unix(path) end |
Instance Method Details
#notify(method, *args) ⇒ 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 |
# File 'lib/neovim/event_loop.rb', line 65 def notify(method, *args) log(:debug) { {name: method, arguments: args} } write(:notification, method, args) end |
#register_types(api, session) ⇒ 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.
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/neovim/event_loop.rb', line 90 def register_types(api, session) api.types.each do |type, info| id = info.fetch("id") klass = Neovim.const_get(type) log(:debug) { {type: type, id: id} } @connection.register_type(id) do |index| klass.new(index, session, api) end end end |
#request(request_id, method, *args) ⇒ 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 46 47 48 49 50 51 |
# File 'lib/neovim/event_loop.rb', line 41 def request(request_id, method, *args) log(:debug) do { request_id: request_id, method: method, arguments: args } end write(:request, request_id, method, args) end |
#respond(request_id, return_value, error) ⇒ 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 59 60 61 62 63 |
# File 'lib/neovim/event_loop.rb', line 53 def respond(request_id, return_value, error) log(:debug) do { request_id: request_id, return_value: return_value, error: error } end write(:response, request_id, error, return_value) end |
#run(&callback) ⇒ 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.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/neovim/event_loop.rb', line 70 def run(&callback) @running = true loop do break if !@running break if @shutdown begin callback.call(read) rescue EOFError => e log_exception(:debug, e, __method__) shutdown rescue => e log_exception(:error, e, __method__) end end ensure @connection.close if @shutdown end |
#shutdown ⇒ 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.
36 37 38 39 |
# File 'lib/neovim/event_loop.rb', line 36 def shutdown stop @shutdown = true end |
#stop ⇒ 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.
32 33 34 |
# File 'lib/neovim/event_loop.rb', line 32 def stop @running = false end |