123456789_123456789_123456789_123456789_123456789_

Class: Prism::CodeUnitsCache::LengthCounter

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: lib/prism/parse_result.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(source, encoding) ⇒ LengthCounter

[ GitHub ]

  
# File 'lib/prism/parse_result.rb', line 185

def initialize(source, encoding)
  @source = source
  @encoding = encoding
end

Instance Method Details

#count(byte_offset, byte_length)

[ GitHub ]

  
# File 'lib/prism/parse_result.rb', line 190

def count(byte_offset, byte_length)
  @source.byteslice(byte_offset, byte_length).encode(@encoding, invalid: :replace, undef: :replace).length
end