Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Ruby::Prism::CodeUnitsCache.new
new(source, encoding)
lib/ruby/prism/parse_result.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/ruby/prism/parse_result.rb, line 306
def initialize(source, encoding)
@source = source
@counter =
case encoding
when Encoding::UTF_8
UTF8Counter.new
when Encoding::UTF_16LE, Encoding::UTF_16BE
UTF16Counter.new(source, encoding)
else
UTF32Counter.new(source, encoding)
end
@cache = {} #: Hash[Integer, Integer]
@offsets = [] #: Array[Integer]
end
Initialize a new cache with the given source and encoding.
See also
#[]