Class: Spoom::LSP::Range

Inherits:
Object
  • Object
show all
Includes:
PrintableSymbol
Defined in:
lib/spoom/sorbet/lsp/structures.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_pos:, end_pos:) ⇒ Range

: (start_pos: Position, end_pos: Position) -> void



63
64
65
66
# File 'lib/spoom/sorbet/lsp/structures.rb', line 63

def initialize(start_pos:, end_pos:)
  @start_pos = start_pos
  @end_pos = end_pos
end

Instance Attribute Details

#end_pos ⇒ Object (readonly)

: Position



60
61
62
# File 'lib/spoom/sorbet/lsp/structures.rb', line 60

def end_pos
  @end_pos
end

#start_pos ⇒ Object (readonly)

: Position



57
58
59
# File 'lib/spoom/sorbet/lsp/structures.rb', line 57

def start_pos
  @start_pos
end

Class Method Details

.from_json(json) ⇒ Object

: (Hash[untyped, untyped] json) -> Range



70
71
72
73
74
75
# File 'lib/spoom/sorbet/lsp/structures.rb', line 70

def from_json(json)
  Range.new(
    start_pos: Position.from_json(json["start"]),
    end_pos: Position.from_json(json["end"]),
  )
end

Instance Method Details

#accept_printer(printer) ⇒ Object

: (SymbolPrinter printer) -> void



80
81
82
83
84
# File 'lib/spoom/sorbet/lsp/structures.rb', line 80

def accept_printer(printer)
  printer.print_object(start_pos)
  printer.print_colored("-", Color::LIGHT_BLACK)
  printer.print_object(end_pos)
end

#to_s ⇒ Object

: -> String



87
88
89
# File 'lib/spoom/sorbet/lsp/structures.rb', line 87

def to_s
  "#{start_pos}-#{end_pos}"
end