Class: Neovim::RemoteObject Abstract
- Inherits:
-
Object
- Object
- Neovim::RemoteObject
- Defined in:
- lib/neovim/remote_object.rb
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) ⇒ RemoteObject
constructor
A new instance of RemoteObject.
-
#method_missing(method_name, *args) ⇒ Object
Intercept method calls and delegate to appropriate RPC methods.
-
#methods ⇒ Object
Extend
methods
to include RPC methods. -
#respond_to?(method_name) ⇒ Boolean
Extend
respond_to?
to support RPC methods. -
#to_msgpack(packer) ⇒ String
Serialize object to MessagePack.
Constructor Details
#initialize(index, session) ⇒ RemoteObject
Returns a new instance of RemoteObject.
10 11 12 13 14 |
# File 'lib/neovim/remote_object.rb', line 10 def initialize(index, session) @index = index @session = session @api = session.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.
25 26 27 28 29 30 31 |
# File 'lib/neovim/remote_object.rb', line 25 def method_missing(method_name, *args) if func = @api.function(qualify(method_name)) func.call(@session, @index, *args) else super end end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
8 9 10 |
# File 'lib/neovim/remote_object.rb', line 8 def index @index end |
Instance Method Details
#==(other) ⇒ Object
Extend == to only look at class and index.
44 45 46 |
# File 'lib/neovim/remote_object.rb', line 44 def ==(other) other.class.equal?(self.class) && @index == other.index end |
#methods ⇒ Object
Extend methods
to include RPC methods
39 40 41 |
# File 'lib/neovim/remote_object.rb', line 39 def methods super | rpc_methods end |
#respond_to?(method_name) ⇒ Boolean
Extend respond_to?
to support RPC methods.
34 35 36 |
# File 'lib/neovim/remote_object.rb', line 34 def respond_to?(method_name) super || rpc_methods.include?(method_name.to_sym) end |
#to_msgpack(packer) ⇒ String
Serialize object to MessagePack.
20 21 22 |
# File 'lib/neovim/remote_object.rb', line 20 def to_msgpack(packer) packer.pack(@index) end |