Class: Neovim::Client
Defined Under Namespace
Classes: UnknownApiFunction, UnknownApiObjectFunction
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.
25
26
27
28
29
|
# File 'lib/neovim/client.rb', line 25
def initialize comm, channel_id
@comm, @channel_id = comm, channel_id
@functions = {}
@objfuncs = Hash.new do |h,k| h[k] = {} end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
62
63
64
65
66
|
# File 'lib/neovim/client.rb', line 62
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.
23
24
25
|
# File 'lib/neovim/client.rb', line 23
def channel_id
@channel_id
end
|
Instance Method Details
#add_functions(list, prefixes) ⇒ Object
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/neovim/client.rb', line 35
def add_functions list, prefixes
list.each { |fn|
next if fn[ "deprecated_since"] && self.class.strict
n = fn[ "name"]
next unless n =~ /\Anvim_/
@functions[ $'.to_sym] = n
t, = prefixes.find { |t,p| n =~ p }
@objfuncs[ t][ $'.to_sym] = n if t
}
end
|
#call_api(name, *args) ⇒ Object
47
48
49
50
51
|
# File 'lib/neovim/client.rb', line 47
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
53
54
55
56
57
58
|
# File 'lib/neovim/client.rb', line 53
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
101
|
# File 'lib/neovim/client.rb', line 101
def command arg ; call_api :command, arg ; end
|
#evaluate(expr) ⇒ Object
103
|
# File 'lib/neovim/client.rb', line 103
def evaluate expr ; call_api :eval, expr ; end
|
#has_obj_function?(obj, name) ⇒ Boolean
82
83
84
|
# File 'lib/neovim/client.rb', line 82
def has_obj_function? obj, name
@objfuncs[ obj.type][ name.to_sym].to_bool
end
|
31
32
33
|
# File 'lib/neovim/client.rb', line 31
def inspect
"#<#{self.class} #@channel_id>"
end
|
#message(str) ⇒ Object
92
93
94
95
|
# File 'lib/neovim/client.rb', line 92
def message str
call_api :out_write, str
str.end_with? $/ or call_api :out_write, $/
end
|
#methods(regular = true) ⇒ Object
75
76
77
78
79
|
# File 'lib/neovim/client.rb', line 75
def methods regular = true
s = super
s |= @functions.keys if regular
s
end
|
#obj_functions(obj) ⇒ Object
86
87
88
|
# File 'lib/neovim/client.rb', line 86
def obj_functions obj
@objfuncs[ obj.type].keys
end
|
#respond_to_missing?(sym, priv = nil) ⇒ Boolean
68
69
70
71
72
73
|
# File 'lib/neovim/client.rb', line 68
def respond_to_missing? sym, priv = nil
@functions[ sym.to_sym].to_bool
end
|