Class: Neovim::RemoteObject

Inherits:
Object show all
Includes:
OptionAccess
Defined in:
lib/neovim/remote_object.rb

Direct Known Subclasses

Buffer, Tabpage, Window

Constant Summary collapse

TRANSFER =

Neovim packs it twice.

MPLight::Types.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from OptionAccess

#get_option, #option_params, #set_option

Constructor Details

#initialize(index, client) ⇒ RemoteObject



68
69
70
# File 'lib/neovim/remote_object.rb', line 68

def initialize index, client
  @index, @client = index, client
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



110
111
112
113
114
# File 'lib/neovim/remote_object.rb', line 110

def method_missing sym, *args
  call_obj sym, *args
rescue UnknownApiObjectFunction
  super
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



66
67
68
# File 'lib/neovim/remote_object.rb', line 66

def client
  @client
end

#indexObject (readonly)

Returns the value of attribute index.



66
67
68
# File 'lib/neovim/remote_object.rb', line 66

def index
  @index
end

Class Method Details

.from_mpdata(data, client) ⇒ Object



89
90
91
92
93
# File 'lib/neovim/remote_object.rb', line 89

def from_mpdata data, client
  b = MPLight::BufferIO.new data
  index = TRANSFER.do_input b do TRANSFER.get end
  new index, client
end

.new(index, client) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/neovim/remote_object.rb', line 50

def new index, client
  @objs ||= []
  i = @objs.find { |s| s.index == index && s.client == client }
  unless i then
    i = plain_new index, client
    @objs.push i
  end
  i
end

.plain_newObject



49
# File 'lib/neovim/remote_object.rb', line 49

alias plain_new new

.typeObject



60
61
62
# File 'lib/neovim/remote_object.rb', line 60

def type
  @type ||= plain_name.to_sym
end

Instance Method Details

#==(other) ⇒ Object



96
97
98
# File 'lib/neovim/remote_object.rb', line 96

def == other
  (other.class.equal? self.class) && @index == other.index && @client == other.client
end

#call_api(name, *args, &block) ⇒ Object



101
102
103
# File 'lib/neovim/remote_object.rb', line 101

def call_api name, *args, &block
  @client.call_api name, *args, &block
end

#call_obj(name, *args, &block) ⇒ Object



105
106
107
# File 'lib/neovim/remote_object.rb', line 105

def call_obj name, *args, &block
  @client.call_obj self, name, *args, &block
end

#inspectObject



76
77
78
# File 'lib/neovim/remote_object.rb', line 76

def inspect
  "#<#{self.class}:#{self.object_id} #@index>"
end

#methods(regular = true) ⇒ Object



120
121
122
123
124
# File 'lib/neovim/remote_object.rb', line 120

def methods regular = true
  s = super
  s |= @client.obj_functions self if regular
  s
end

#respond_to_missing?(sym, priv = nil) ⇒ Boolean



116
117
118
# File 'lib/neovim/remote_object.rb', line 116

def respond_to_missing? sym, priv = nil
  @client.has_obj_function? self, sym
end

#to_mpdata(packer = nil) ⇒ Object



83
84
85
86
87
# File 'lib/neovim/remote_object.rb', line 83

def to_mpdata packer = nil
  b = MPLight::BufferIO.new
  TRANSFER.do_output b do TRANSFER.put @index end
  b.data
end

#typeObject



72
73
74
# File 'lib/neovim/remote_object.rb', line 72

def type
  self.class.type
end