Class: LanguageServer::Protocol::Interface::Position

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributesObject (readonly)

Returns the value of attribute attributes.



34
35
36
# File 'lib/language_server/protocol/interface/position.rb', line 34

def attributes
  @attributes
end

Instance Method Details

#characternumber

Character offset on a line in a document (zero-based). The meaning of this offset is determined by the negotiated ‘PositionEncodingKind`.

If the character value is greater than the line length it defaults back to the line length.

Returns:

  • (number)


30
31
32
# File 'lib/language_server/protocol/interface/position.rb', line 30

def character
  attributes.fetch(:character)
end

#linenumber

Line position in a document (zero-based).

Returns:

  • (number)


18
19
20
# File 'lib/language_server/protocol/interface/position.rb', line 18

def line
  attributes.fetch(:line)
end

#to_hashObject



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

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



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

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