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: extent_calculator.rb
    path of file: ./repos/archivesspace/backend/app/model
    
    the code of the file until where you have to start completion: class ExtentCalculator

  attr_reader :units

  Unit_conversions = {
    :inches => {
      :centimeters => 2.54,
      :feet => 1.0/12.0,
      :meters => 0.0254
    },
    :centimeters => {
  
    
  def total_extent(recalculate = false)
    return published_extent if @calculated_extent && !recalculate

    extent = 0

    topcon_rlshp = SubContainer.find_relationship(:top_container_link)
    rel_ids = @root_object.object_graph.ids_for(topcon_rlshp)

    DB.open do |db|
      db[:top_container_link_rlshp].filter(:id => rel_ids).select(:top_container_id).
        distinct().map {|hash| hash[:top_container_id]}.each do |tc_id|

        @container_count += 1

        if (rec = TopContainer[tc_id].related_records(:top_container_profile))
          key = @volume ? rec.name : rec.display_string
          @containers[key] ||= {:count => 0, :extent => 0.0}
          @containers[key][:count] += 1
          ext = if @volume
                  vol = 1.0
                  [:width, :height, :depth].each {|dim| vol = rec.send(dim).to_f * vol }
                  convert(vol, rec.dimension_units.intern)
                else
                  convert(rec.send(rec.extent_dimension.intern).to_f, rec.dimension_units.intern)
                end
          @containers[key][:extent] += ext
          extent += ext
        else
          # top container does not have a container profile
          if @strict
            raise "Container without Profile found"
          else
            @container_without_profile_count += 1
          end
        end
      end