Class: LanguageServer::Protocol::Interface::RequestMessage

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Message

#jsonrpc

Constructor Details

#initialize(jsonrpc:, id:, method:, params: nil) ⇒ RequestMessage

Returns a new instance of RequestMessage.



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

def initialize(jsonrpc:, id:, method:, params: nil)
  @attributes = {}

  @attributes[:jsonrpc] = jsonrpc
  @attributes[:id] = id
  @attributes[:method] = method
  @attributes[:params] = params if params

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



40
41
42
# File 'lib/language_server/protocol/interface/request_message.rb', line 40

def attributes
  @attributes
end

Instance Method Details

#idstring | number

The request id.

Returns:

  • (string | number)


20
21
22
# File 'lib/language_server/protocol/interface/request_message.rb', line 20

def id
  attributes.fetch(:id)
end

#methodstring

The method to be invoked.

Returns:

  • (string)


28
29
30
# File 'lib/language_server/protocol/interface/request_message.rb', line 28

def method
  attributes.fetch(:method)
end

#paramsobject | any[]

The method’s params.

Returns:

  • (object | any[])


36
37
38
# File 'lib/language_server/protocol/interface/request_message.rb', line 36

def params
  attributes.fetch(:params)
end

#to_hashObject



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

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



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

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