Class: Spoom::Sorbet::Sigs::Scanner
- Inherits:
-
Object
- Object
- Spoom::Sorbet::Sigs::Scanner
- Extended by:
- T::Sig
- Defined in:
- lib/spoom/sorbet/sigs.rb
Overview
Constant Summary collapse
- LINE_BREAK =
T.let(0x0A, Integer)
Instance Method Summary collapse
- #find_char_position(line, character) ⇒ Object
-
#initialize(source) ⇒ Scanner
constructor
A new instance of Scanner.
Constructor Details
#initialize(source) ⇒ Scanner
Returns a new instance of Scanner.
151 152 153 154 155 |
# File 'lib/spoom/sorbet/sigs.rb', line 151 def initialize(source) @current_line = T.let(0, Integer) @pos = T.let(0, Integer) @source = T.let(source.codepoints, T::Array[Integer]) end |
Instance Method Details
#find_char_position(line, character) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/spoom/sorbet/sigs.rb', line 159 def find_char_position(line, character) # Find the character index for the beginning of the requested line until @current_line == line @pos += 1 until LINE_BREAK == @source[@pos] @pos += 1 @current_line += 1 end # The final position is the beginning of the line plus the requested column @pos + character end |