Class: Neovim::API
- Inherits:
-
Object
- Object
- Neovim::API
- Defined in:
- lib/neovim/api.rb
Defined Under Namespace
Classes: Function
Class Method Summary collapse
-
.null ⇒ API
Represents an unknown API.
Instance Method Summary collapse
-
#channel_id ⇒ Fixnum?
Return the channel ID of the current RPC session.
-
#function(name) ⇒ Function?
Find a function with the given name.
-
#functions ⇒ Array<Function>
Return all functions defined by the API, as
Function
objects. -
#functions_with_prefix(prefix) ⇒ Array<Function>
Return a list of functions with the given name prefix.
-
#initialize(data) ⇒ API
constructor
A new instance of API.
-
#inspect ⇒ String
Truncate the output of inspect so console sessions are more pleasant.
-
#types ⇒ Hash
Return information about
nvim
types.
Constructor Details
#initialize(data) ⇒ API
Returns a new instance of API.
11 12 13 |
# File 'lib/neovim/api.rb', line 11 def initialize(data) @data = data end |
Class Method Details
.null ⇒ API
Represents an unknown API. Used as a stand-in when the API hasn’t been discovered yet via the vim_get_api_info
RPC call.
7 8 9 |
# File 'lib/neovim/api.rb', line 7 def self.null new([nil, {"functions" => [], "types" => []}]) end |
Instance Method Details
#channel_id ⇒ Fixnum?
Return the channel ID of the current RPC session.
36 37 38 |
# File 'lib/neovim/api.rb', line 36 def channel_id @channel_id ||= @data.fetch(0) end |
#function(name) ⇒ Function?
Find a function with the given name.
54 55 56 57 58 |
# File 'lib/neovim/api.rb', line 54 def function(name) functions.find do |func| func.name == name.to_s end end |
#functions ⇒ Array<Function>
Return all functions defined by the API, as Function
objects.
19 20 21 22 23 |
# File 'lib/neovim/api.rb', line 19 def functions @functions ||= @data.fetch(1).fetch("functions").map do |func| Function.new(func["name"], func["async"]) end end |
#functions_with_prefix(prefix) ⇒ Array<Function>
Return a list of functions with the given name prefix.
44 45 46 47 48 |
# File 'lib/neovim/api.rb', line 44 def functions_with_prefix(prefix) functions.select do |function| function.name =~ /\A#{prefix}/ end end |
#inspect ⇒ String
Truncate the output of inspect so console sessions are more pleasant.
63 64 65 |
# File 'lib/neovim/api.rb', line 63 def inspect "#<#{self.class}:0x%x @types={...} @functions={...}>" % (object_id << 1) end |
#types ⇒ Hash
Return information about nvim
types. Used for registering MessagePack ext
types.
29 30 31 |
# File 'lib/neovim/api.rb', line 29 def types @types ||= @data.fetch(1).fetch("types") end |