Class: LanguageServer::Protocol::Interface::ColorPresentation
- Inherits:
-
Object
- Object
- LanguageServer::Protocol::Interface::ColorPresentation
- Defined in:
- lib/language_server/protocol/interface/color_presentation.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#additional_text_edits ⇒ TextEdit[]
An optional array of additional [text edits](#TextEdit) that are applied when selecting this color presentation.
-
#initialize(label:, text_edit: nil, additional_text_edits: nil) ⇒ ColorPresentation
constructor
A new instance of ColorPresentation.
-
#label ⇒ string
The label of this color presentation.
-
#text_edit ⇒ TextEdit
An [edit](#TextEdit) which is applied to a document when selecting this presentation for the color.
- #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(label:, text_edit: nil, additional_text_edits: nil) ⇒ ColorPresentation
Returns a new instance of ColorPresentation.
5 6 7 8 9 10 11 12 13 |
# File 'lib/language_server/protocol/interface/color_presentation.rb', line 5 def initialize(label:, text_edit: nil, additional_text_edits: nil) @attributes = {} @attributes[:label] = label @attributes[:textEdit] = text_edit if text_edit @attributes[:additionalTextEdits] = additional_text_edits if additional_text_edits @attributes.freeze end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
45 46 47 |
# File 'lib/language_server/protocol/interface/color_presentation.rb', line 45 def attributes @attributes end |
Instance Method Details
#additional_text_edits ⇒ TextEdit[]
An optional array of additional [text edits](#TextEdit) that are applied when selecting this color presentation. Edits must not overlap with the main [edit](#ColorPresentation.textEdit) nor with themselves.
41 42 43 |
# File 'lib/language_server/protocol/interface/color_presentation.rb', line 41 def additional_text_edits attributes.fetch(:additionalTextEdits) end |
#label ⇒ string
The label of this color presentation. It will be shown on the color picker header. By default this is also the text that is inserted when selecting this color presentation.
21 22 23 |
# File 'lib/language_server/protocol/interface/color_presentation.rb', line 21 def label attributes.fetch(:label) end |
#text_edit ⇒ TextEdit
An [edit](#TextEdit) which is applied to a document when selecting this presentation for the color. When ‘falsy` the [label](#ColorPresentation.label) is used.
31 32 33 |
# File 'lib/language_server/protocol/interface/color_presentation.rb', line 31 def text_edit attributes.fetch(:textEdit) end |
#to_hash ⇒ Object
47 48 49 |
# File 'lib/language_server/protocol/interface/color_presentation.rb', line 47 def to_hash attributes end |
#to_json(*args) ⇒ Object
51 52 53 |
# File 'lib/language_server/protocol/interface/color_presentation.rb', line 51 def to_json(*args) to_hash.to_json(*args) end |