Class: Neovim::RemoteObject Abstract
Overview
This class is abstract.
Superclass for all nvim
remote objects.
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Extend == to only look at class and index.
-
#initialize(index, session, api) ⇒ RemoteObject
constructor
A new instance of RemoteObject.
-
#method_missing(method_name, *args) ⇒ Object
Intercept method calls and delegate to appropriate RPC methods.
-
#methods(*args) ⇒ Object
Extend
methods
to include RPC methods. -
#respond_to_missing?(method_name) ⇒ Boolean
Extend
respond_to_missing?
to support RPC methods. -
#to_msgpack(packer) ⇒ String
Serialize object to MessagePack.
Constructor Details
#initialize(index, session, api) ⇒ RemoteObject
Returns a new instance of RemoteObject.
12 13 14 15 16 |
# File 'lib/neovim/remote_object.rb', line 12 def initialize(index, session, api) @index = index @session = session @api = api end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
Intercept method calls and delegate to appropriate RPC methods.
27 28 29 30 31 32 33 |
# File 'lib/neovim/remote_object.rb', line 27 def method_missing(method_name, *args) if (func = @api.function_for_object_method(self, method_name)) func.call(@session, @index, *args) else super end end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
10 11 12 |
# File 'lib/neovim/remote_object.rb', line 10 def index @index end |
Instance Method Details
#==(other) ⇒ Object
Extend == to only look at class and index.
46 47 48 |
# File 'lib/neovim/remote_object.rb', line 46 def ==(other) other.class.equal?(self.class) && @index == other.index end |
#methods(*args) ⇒ Object
Extend methods
to include RPC methods
41 42 43 |
# File 'lib/neovim/remote_object.rb', line 41 def methods(*args) super | rpc_methods.to_a end |
#respond_to_missing?(method_name) ⇒ Boolean
Extend respond_to_missing?
to support RPC methods.
36 37 38 |
# File 'lib/neovim/remote_object.rb', line 36 def respond_to_missing?(method_name, *) super || rpc_methods.include?(method_name.to_sym) end |
#to_msgpack(packer) ⇒ String
Serialize object to MessagePack.
22 23 24 |
# File 'lib/neovim/remote_object.rb', line 22 def to_msgpack(packer) packer.pack(@index) end |