Class: Neovim::Session::API Private
- Inherits:
-
Object
- Object
- Neovim::Session::API
- Defined in:
- lib/neovim/session/api.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.
Defined Under Namespace
Classes: Function
Instance Attribute Summary collapse
- #channel_id ⇒ Object readonly private
Class Method Summary collapse
-
.null ⇒ Object
private
Represents an unknown API.
Instance Method Summary collapse
-
#function(name) ⇒ Object
private
Find a function with the given name.
-
#functions ⇒ Object
private
Return all functions defined by the API.
-
#functions_with_prefix(prefix) ⇒ Object
private
Return a list of functions with the given name prefix.
-
#initialize(payload) ⇒ API
constructor
private
A new instance of API.
-
#inspect ⇒ Object
private
Truncate the output of inspect so console sessions are more pleasant.
-
#types ⇒ Object
private
Return information about
nvimtypes.
Constructor Details
#initialize(payload) ⇒ API
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 API.
13 14 15 |
# File 'lib/neovim/session/api.rb', line 13 def initialize(payload) @channel_id, @api_info = payload end |
Instance Attribute Details
#channel_id ⇒ Object (readonly)
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.
5 6 7 |
# File 'lib/neovim/session/api.rb', line 5 def channel_id @channel_id end |
Class Method Details
.null ⇒ 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.
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.
9 10 11 |
# File 'lib/neovim/session/api.rb', line 9 def self.null new([nil, {"functions" => [], "types" => []}]) end |
Instance Method Details
#function(name) ⇒ 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.
Find a function with the given name.
39 40 41 |
# File 'lib/neovim/session/api.rb', line 39 def function(name) functions[name.to_s] end |
#functions ⇒ 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.
Return all functions defined by the API.
18 19 20 21 22 23 |
# File 'lib/neovim/session/api.rb', line 18 def functions @functions ||= @api_info.fetch("functions").inject({}) do |acc, func| name, async = func.values_at("name", "async") acc.merge(name => Function.new(name, async)) end end |
#functions_with_prefix(prefix) ⇒ 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.
Return a list of functions with the given name prefix.
32 33 34 35 36 |
# File 'lib/neovim/session/api.rb', line 32 def functions_with_prefix(prefix) functions.inject([]) do |acc, (name, function)| name =~ /\A#{prefix}/ ? acc.push(function) : acc end end |
#inspect ⇒ 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.
Truncate the output of inspect so console sessions are more pleasant.
44 45 46 |
# File 'lib/neovim/session/api.rb', line 44 def inspect "#<#{self.class}:0x%x @types={...} @functions={...}>" % (object_id << 1) end |
#types ⇒ 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.
Return information about nvim types. Used for registering MessagePack ext types.
27 28 29 |
# File 'lib/neovim/session/api.rb', line 27 def types @types ||= @api_info.fetch("types") end |