123456789_123456789_123456789_123456789_123456789_

Class: Prism::CodeUnitsCache::UTF16Counter

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) ⇒ UTF16Counter

[ GitHub ]

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

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 179

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