Class: LanguageServer::Protocol::Interface::Position
- Inherits:
-
Object
- Object
- LanguageServer::Protocol::Interface::Position
- Defined in:
- lib/language_server/protocol/interface/position.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#character ⇒ number
Character offset on a line in a document (zero-based).
-
#initialize(line:, character:) ⇒ Position
constructor
A new instance of Position.
-
#line ⇒ number
Line position in a document (zero-based).
- #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(line:, character:) ⇒ Position
Returns a new instance of Position.
5 6 7 8 9 10 11 12 |
# File 'lib/language_server/protocol/interface/position.rb', line 5 def initialize(line:, character:) @attributes = {} @attributes[:line] = line @attributes[:character] = character @attributes.freeze end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
35 36 37 |
# File 'lib/language_server/protocol/interface/position.rb', line 35 def attributes @attributes end |
Instance Method Details
#character ⇒ number
Character offset on a line in a document (zero-based). Assuming that the line is represented as a string, the ‘character` value represents the gap between the `character` and `character + 1`.
If the character value is greater than the line length it defaults back to the line length.
31 32 33 |
# File 'lib/language_server/protocol/interface/position.rb', line 31 def character attributes.fetch(:character) end |
#line ⇒ number
Line position in a document (zero-based).
18 19 20 |
# File 'lib/language_server/protocol/interface/position.rb', line 18 def line attributes.fetch(:line) end |
#to_hash ⇒ Object
37 38 39 |
# File 'lib/language_server/protocol/interface/position.rb', line 37 def to_hash attributes end |
#to_json(*args) ⇒ Object
41 42 43 |
# File 'lib/language_server/protocol/interface/position.rb', line 41 def to_json(*args) to_hash.to_json(*args) end |