Class: LanguageServer::Protocol::Interface::Command
- Inherits:
-
Object
- Object
- LanguageServer::Protocol::Interface::Command
- Defined in:
- lib/language_server/protocol/interface/command.rb
Overview
Represents a reference to a command. Provides a title which will be used to represent a command in the UI and, optionally, an array of arguments which will be passed to the command handler function when invoked.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#arguments ⇒ LSPAny[] | nil
Arguments that the command handler should be invoked with.
-
#command ⇒ string
The identifier of the actual command handler.
-
#initialize(title:, command:, arguments: nil) ⇒ Command
constructor
A new instance of Command.
-
#title ⇒ string
Title of the command, like
save. - #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(title:, command:, arguments: nil) ⇒ Command
Returns a new instance of Command.
11 12 13 14 15 16 17 18 19 |
# File 'lib/language_server/protocol/interface/command.rb', line 11 def initialize(title:, command:, arguments: nil) @attributes = {} @attributes[:title] = title @attributes[:command] = command @attributes[:arguments] = arguments if arguments @attributes.freeze end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
46 47 48 |
# File 'lib/language_server/protocol/interface/command.rb', line 46 def attributes @attributes end |
Instance Method Details
#arguments ⇒ LSPAny[] | nil
Arguments that the command handler should be invoked with.
42 43 44 |
# File 'lib/language_server/protocol/interface/command.rb', line 42 def arguments attributes.fetch(:arguments) end |
#command ⇒ string
The identifier of the actual command handler.
33 34 35 |
# File 'lib/language_server/protocol/interface/command.rb', line 33 def command attributes.fetch(:command) end |
#title ⇒ string
Title of the command, like save.
25 26 27 |
# File 'lib/language_server/protocol/interface/command.rb', line 25 def title attributes.fetch(:title) end |
#to_hash ⇒ Object
48 49 50 |
# File 'lib/language_server/protocol/interface/command.rb', line 48 def to_hash attributes end |
#to_json(*args) ⇒ Object
52 53 54 |
# File 'lib/language_server/protocol/interface/command.rb', line 52 def to_json(*args) to_hash.to_json(*args) end |