class Neovim::API
@api private
Attributes
channel_id[R]
Public Class Methods
new(payload)
click to toggle source
# File lib/neovim/api.rb, line 6 def initialize(payload) @channel_id, @api_info = payload end
Public Instance Methods
function_for_object_method(obj, method_name)
click to toggle source
# File lib/neovim/api.rb, line 24 def function_for_object_method(obj, method_name) functions[function_name(obj, method_name)] end
functions()
click to toggle source
Return all functions defined by the API
.
# File lib/neovim/api.rb, line 11 def functions @functions ||= @api_info.fetch("functions").inject({}) do |acc, func| function = Function.new(func) acc.merge(function.name => function) end end
functions_for_object(obj)
click to toggle source
# File lib/neovim/api.rb, line 28 def functions_for_object(obj) pattern = function_pattern(obj) functions.values.select { |func| func.name =~ pattern } end
inspect()
click to toggle source
Truncate the output of inspect so console sessions are more pleasant.
# File lib/neovim/api.rb, line 34 def inspect format("#<#{self.class}:0x%x @channel_id=#{@channel_id.inspect}>", object_id << 1) end
types()
click to toggle source
Return information about nvim
types. Used for registering MessagePack ext
types.
# File lib/neovim/api.rb, line 20 def types @types ||= @api_info.fetch("types") end
Private Instance Methods
function_name(obj, method_name)
click to toggle source
# File lib/neovim/api.rb, line 40 def function_name(obj, method_name) case obj when Client "nvim_#{method_name}" when Buffer "nvim_buf_#{method_name}" when Window "nvim_win_#{method_name}" when Tabpage "nvim_tabpage_#{method_name}" else raise "Unknown object #{obj.inspect}" end end
function_pattern(obj)
click to toggle source
# File lib/neovim/api.rb, line 55 def function_pattern(obj) case obj when Client /^nvim_(?!(buf|win|tabpage)_)/ when Buffer /^nvim_buf_/ when Window /^nvim_win_/ when Tabpage /^nvim_tabpage_/ else raise "Unknown object #{obj.inspect}" end end