Class: LanguageServer::Protocol::Interface::ResponseMessage
- Defined in:
- lib/language_server/protocol/interface/response_message.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#error ⇒ ResponseError<any>
The error object in case a request fails.
-
#id ⇒ string | number
The request id.
-
#initialize(jsonrpc:, id:, result: nil, error: nil) ⇒ ResponseMessage
constructor
A new instance of ResponseMessage.
-
#result ⇒ any
The result of a request.
- #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
Methods inherited from Message
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 |
# File 'lib/language_server/protocol/interface/response_message.rb', line 5 def initialize(jsonrpc:, id:, result: nil, error: nil) @attributes = {} @attributes[:id] = id @attributes[:result] = result if result @attributes[:error] = error if error @attributes.freeze end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
40 41 42 |
# File 'lib/language_server/protocol/interface/response_message.rb', line 40 def attributes @attributes end |
Instance Method Details
#error ⇒ ResponseError<any>
The error object in case a request fails.
36 37 38 |
# File 'lib/language_server/protocol/interface/response_message.rb', line 36 def error attributes.fetch(:error) end |
#id ⇒ string | number
The request id.
19 20 21 |
# File 'lib/language_server/protocol/interface/response_message.rb', line 19 def id attributes.fetch(:id) end |
#result ⇒ any
The result of a request. This can be omitted in the case of an error.
28 29 30 |
# File 'lib/language_server/protocol/interface/response_message.rb', line 28 def result attributes.fetch(:result) end |
#to_hash ⇒ Object
42 43 44 |
# File 'lib/language_server/protocol/interface/response_message.rb', line 42 def to_hash attributes end |
#to_json(*args) ⇒ Object
46 47 48 |
# File 'lib/language_server/protocol/interface/response_message.rb', line 46 def to_json(*args) to_hash.to_json(*args) end |