Class: Mui::Lsp::Protocol::Position

Inherits:
Object
  • Object
show all
Defined in:
lib/mui/lsp/protocol/position.rb

Overview

LSP Position (0-indexed line and character)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line:, character:) ⇒ Position

Returns a new instance of Position.



10
11
12
13
# File 'lib/mui/lsp/protocol/position.rb', line 10

def initialize(line:, character:)
  @line = line
  @character = character
end

Instance Attribute Details

#characterObject

Returns the value of attribute character.



8
9
10
# File 'lib/mui/lsp/protocol/position.rb', line 8

def character
  @character
end

#lineObject

Returns the value of attribute line.



8
9
10
# File 'lib/mui/lsp/protocol/position.rb', line 8

def line
  @line
end

Class Method Details

.from_hash(hash) ⇒ Object



19
20
21
# File 'lib/mui/lsp/protocol/position.rb', line 19

def self.from_hash(hash)
  new(line: hash["line"] || hash[:line], character: hash["character"] || hash[:character])
end

Instance Method Details

#==(other) ⇒ Object



23
24
25
26
27
# File 'lib/mui/lsp/protocol/position.rb', line 23

def ==(other)
  return false unless other.is_a?(Position)

  @line == other.line && @character == other.character
end

#to_hObject



15
16
17
# File 'lib/mui/lsp/protocol/position.rb', line 15

def to_h
  { line: @line, character: @character }
end