Class: LanguageServer::Protocol::Interface::ResponseMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/language_server/protocol/interface/response_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(jsonrpc:, id:, result: nil, error: nil) ⇒ ResponseMessage

Returns a new instance of ResponseMessage.



5
6
7
8
9
10
11
12
13
14
# File 'lib/language_server/protocol/interface/response_message.rb', line 5

def initialize(jsonrpc:, id:, result: nil, error: nil)
  @attributes = {}

  @attributes[:jsonrpc] = jsonrpc
  @attributes[:id] = id
  @attributes[:result] = result if result
  @attributes[:error] = error if error

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



46
47
48
# File 'lib/language_server/protocol/interface/response_message.rb', line 46

def attributes
  @attributes
end

Instance Method Details

#errorResponseError

The error object in case a request fails.

Returns:



42
43
44
# File 'lib/language_server/protocol/interface/response_message.rb', line 42

def error
  attributes.fetch(:error)
end

#idstring | number

The request id.

Returns:

  • (string | number)


25
26
27
# File 'lib/language_server/protocol/interface/response_message.rb', line 25

def id
  attributes.fetch(:id)
end

#jsonrpcstring

Returns:

  • (string)


17
18
19
# File 'lib/language_server/protocol/interface/response_message.rb', line 17

def jsonrpc
  attributes.fetch(:jsonrpc)
end

#resultstring | number | boolean | object

The result of a request. This member is REQUIRED on success. This member MUST NOT exist if there was an error invoking the method.

Returns:

  • (string | number | boolean | object)


34
35
36
# File 'lib/language_server/protocol/interface/response_message.rb', line 34

def result
  attributes.fetch(:result)
end

#to_hashObject



48
49
50
# File 'lib/language_server/protocol/interface/response_message.rb', line 48

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



52
53
54
# File 'lib/language_server/protocol/interface/response_message.rb', line 52

def to_json(*args)
  to_hash.to_json(*args)
end