Class: RubyLsp::Document::Scanner
- Inherits:
-
Object
- Object
- RubyLsp::Document::Scanner
- Extended by:
- T::Sig
- Defined in:
- lib/ruby_lsp/document.rb
Instance Method Summary collapse
- #find_position(position) ⇒ Object
-
#initialize(source) ⇒ Scanner
constructor
A new instance of Scanner.
Constructor Details
#initialize(source) ⇒ Scanner
Returns a new instance of Scanner.
108 109 110 111 112 |
# File 'lib/ruby_lsp/document.rb', line 108 def initialize(source) @current_line = T.let(0, Integer) @pos = T.let(0, Integer) @source = source end |
Instance Method Details
#find_position(position) ⇒ Object
115 116 117 118 119 120 121 122 123 |
# File 'lib/ruby_lsp/document.rb', line 115 def find_position(position) until @current_line == position[:line] @pos += 1 until /\R/.match?(@source[@pos]) @pos += 1 @current_line += 1 end @pos + position[:character] end |