Class: Neovim::Client
Constant Summary
collapse
- OPTION_PARAM =
nil
Class Attribute Summary collapse
Instance Attribute Summary collapse
Instance Method Summary
collapse
#get_option, #option_params, #set_option
Constructor Details
#initialize(comm, channel_id) ⇒ Client
Returns a new instance of Client.
22
23
24
25
26
|
# File 'lib/neovim/client.rb', line 22
def initialize comm, channel_id
@comm, @channel_id = comm, channel_id
@functions = {}
@objfuncs = {}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
64
65
66
67
68
|
# File 'lib/neovim/client.rb', line 64
def method_missing sym, *args
call_api sym, *args
rescue UnknownApiFunction
super
end
|
Class Attribute Details
Returns the value of attribute strict.
16
17
18
|
# File 'lib/neovim/client.rb', line 16
def strict
@strict
end
|
Instance Attribute Details
#channel_id ⇒ Object
Returns the value of attribute channel_id.
20
21
22
|
# File 'lib/neovim/client.rb', line 20
def channel_id
@channel_id
end
|
Instance Method Details
#add_functions(list, prefixes) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/neovim/client.rb', line 32
def add_functions list, prefixes
list.each { |fn|
next if fn[ "deprecated_since"] && self.class.strict
n = fn[ "name"]
if (b = n.starts_with? "nvim_") then
@functions[ n[ b...].to_sym] = n
end
prefixes.each { |t,p|
if (b = n.starts_with? p) then
@objfuncs[ t] ||= {}
@objfuncs[ t][ n[ b...].to_sym] = n
break
end
}
}
end
|
#call_api(name, *args) ⇒ Object
50
51
52
53
54
|
# File 'lib/neovim/client.rb', line 50
def call_api name, *args
f = @functions[ name.to_sym]
f or raise UnknownApiFunction, "Function: #{name}"
@comm.request f, *args
end
|
#call_obj(obj, name, *args) ⇒ Object
56
57
58
59
60
61
|
# File 'lib/neovim/client.rb', line 56
def call_obj obj, name, *args
n = obj.type
f = @objfuncs[ n.to_sym][ name.to_sym]
f or raise UnknownApiObjectFunction, "Object: #{n}, Function: #{name}"
@comm.request f, obj.index, *args
end
|
#command(arg) ⇒ Object
110
|
# File 'lib/neovim/client.rb', line 110
def command arg ; call_api :command, arg ; end
|
#evaluate(expr) ⇒ Object
Be aware that #eval was a private instance method from module Kernel.
113
|
# File 'lib/neovim/client.rb', line 113
def evaluate expr ; call_api :eval, expr ; end
|
#functions ⇒ Object
83
84
85
|
# File 'lib/neovim/client.rb', line 83
def functions
@functions.keys
end
|
#has_obj_function?(obj, name) ⇒ Boolean
88
89
90
|
# File 'lib/neovim/client.rb', line 88
def has_obj_function? obj, name
@objfuncs[ obj.type][ name.to_sym].to_bool
end
|
28
29
30
|
# File 'lib/neovim/client.rb', line 28
def inspect
"#<#{self.class} #@channel_id>"
end
|
#message(str) ⇒ Object
101
102
103
104
|
# File 'lib/neovim/client.rb', line 101
def message str
call_api :out_write, str
str.end_with? $/ or call_api :out_write, $/
end
|
#methods(regular = true) ⇒ Object
77
78
79
80
81
|
# File 'lib/neovim/client.rb', line 77
def methods regular = true
s = super
s |= @functions.keys if regular
s
end
|
#obj_classes ⇒ Object
92
93
94
|
# File 'lib/neovim/client.rb', line 92
def obj_classes
RemoteObject.subclasses.select { |c| @objfuncs[ c.type] rescue nil }
end
|
#obj_functions(obj) ⇒ Object
96
97
98
|
# File 'lib/neovim/client.rb', line 96
def obj_functions obj
@objfuncs[ obj.type].keys
end
|
#respond_to_missing?(sym, priv = nil) ⇒ Boolean
70
71
72
73
74
75
|
# File 'lib/neovim/client.rb', line 70
def respond_to_missing? sym, priv = nil
@functions[ sym.to_sym].to_bool
end
|