Class: LanguageServer::Protocol::Interface::Command

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, command:, arguments: nil) ⇒ Command

Returns a new instance of Command.



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

def initialize(title:, command:, arguments: nil)
  @attributes = {}

  @attributes[:title] = title
  @attributes[:command] = command
  @attributes[:arguments] = arguments if arguments

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

Instance Method Details

#argumentsany[]

Arguments that the command handler should be invoked with.

Returns:

  • (any[])


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

def arguments
  attributes.fetch(:arguments)
end

#commandstring

The identifier of the actual command handler.

Returns:

  • (string)


27
28
29
# File 'lib/language_server/protocol/interface/command.rb', line 27

def command
  attributes.fetch(:command)
end

#titlestring

Title of the command, like ‘save`.

Returns:

  • (string)


19
20
21
# File 'lib/language_server/protocol/interface/command.rb', line 19

def title
  attributes.fetch(:title)
end

#to_hashObject



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

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



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

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