You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: file_operations.rb
    path of file: ./repos/truffleruby/src/main/ruby/truffleruby/core/truffle
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

# Copyright (c)
    
    def self.dirname(path)
      slash = '/'

      # pull off any /'s at the end to ignore
      chunk_size = last_nonslash(path)
      return +'/' unless chunk_size

      if pos = Primitive.find_string_reverse(path, slash, chunk_size)
        return +'/' if pos == 0

        path = path.byteslice(0, pos)

        return +'/' if path == '/'

        return path unless path.end_with? slash

        # prune any trailing /'s
        idx = last_nonslash(path, pos)

        # edge case, only /'s, return /
        return +'/' unless idx

        return path.byteslice(0, idx - 1)
      end