Class: Mui::Lsp::Protocol::Range
- Inherits:
-
Object
- Object
- Mui::Lsp::Protocol::Range
- Defined in:
- lib/mui/lsp/protocol/range.rb
Overview
LSP Range (start and end positions)
Instance Attribute Summary collapse
-
#end ⇒ Object
Returns the value of attribute end.
-
#start ⇒ Object
Returns the value of attribute start.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(start:, end_pos:) ⇒ Range
constructor
A new instance of Range.
- #to_h ⇒ Object
Constructor Details
#initialize(start:, end_pos:) ⇒ Range
Returns a new instance of Range.
10 11 12 13 |
# File 'lib/mui/lsp/protocol/range.rb', line 10 def initialize(start:, end_pos:) @start = start.is_a?(Position) ? start : Position.from_hash(start) @end = end_pos.is_a?(Position) ? end_pos : Position.from_hash(end_pos) end |
Instance Attribute Details
#end ⇒ Object
Returns the value of attribute end.
8 9 10 |
# File 'lib/mui/lsp/protocol/range.rb', line 8 def end @end end |
#start ⇒ Object
Returns the value of attribute start.
8 9 10 |
# File 'lib/mui/lsp/protocol/range.rb', line 8 def start @start end |
Class Method Details
.from_hash(hash) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/mui/lsp/protocol/range.rb', line 19 def self.from_hash(hash) new( start: hash["start"] || hash[:start], end_pos: hash["end"] || hash[:end] ) end |
Instance Method Details
#==(other) ⇒ Object
26 27 28 29 30 |
# File 'lib/mui/lsp/protocol/range.rb', line 26 def ==(other) return false unless other.is_a?(Range) @start == other.start && @end == other.end end |
#to_h ⇒ Object
15 16 17 |
# File 'lib/mui/lsp/protocol/range.rb', line 15 def to_h { start: @start.to_h, end: @end.to_h } end |