def group(have)
      if have.track
        # Assign a custom track identifier if one was supplied
        have.subtitles.each { |subtitle| subtitle[:track] = have.track }
      elsif @haves.index(have) == 0 || @haves[@haves.index(have) - 1].subtitles.empty?
        # Otherwise let the path be the track identifier for the first subtitle
        have.subtitles.each { |subtitle| subtitle[:track] = have.file }
      else
        # For the 2nd+ subtitles determine the track association by detecting
        # collisions against the previously imported subtitles

        collisions = 0

        have.subtitles.each do |subtitle|
          @haves[@haves.index(have) - 1].subtitles.each do |previous_subtitle|
            collisions += 1 if (subtitle[:start] > previous_subtitle[:start] &&
                                subtitle[:start] < previous_subtitle[:end]) ||
                               (subtitle[:end] > previous_subtitle[:start] &&
                                subtitle[:end] < previous_subtitle[:end]) ||
                               (previous_subtitle[:start] > subtitle[:start] &&
                                previous_subtitle[:start] < subtitle[:end]) ||
                               (previous_subtitle[:end] > subtitle[:start] &&
                                previous_subtitle[:end] < subtitle[:end]) ||
                               (subtitle[:start] == previous_subtitle[:start] ||
                                subtitle[:end] == previous_subtitle[:end])
          end
        end

        if collisions.to_f / have.subtitles.length.to_f > 0.01
          # Add a new track if there are > 1% collisions between these
          # subtitles and the ones that were last imported
          have.subtitles.each { |subtitle| subtitle[:track] = have.file }
        else
          # Otherwise continue using the previous track identifier
          # (= Assume that these and the previous subtitles are one track)
          previous_track = @haves[@haves.index(have) - 1].subtitles.first[:track]
          have.subtitles.each { |subtitle| subtitle[:track] = previous_track }
        end
      end
    end
def group(have)
      if have.track
        # Assign a custom track identifier if one was supplied
        have.subtitles.each { |subtitle| subtitle[:track] = have.track }
      elsif @haves.index(have) == 0 || @haves[@haves.index(have) - 1].subtitles.empty?
        # Otherwise let the path be the track identifier for the first subtitle
        have.subtitles.each { |subtitle| subtitle[:track] = have.file }
      else
        # For the 2nd+ subtitles determine the track association by detecting
        # collisions against the previously imported subtitles

        collisions = 0

        have.subtitles.each do |subtitle|
          @haves[@haves.index(have) - 1].subtitles.each do |previous_subtitle|
            collisions += 1 if (subtitle[:start] > previous_subtitle[:start] &&
                                subtitle[:start] < previous_subtitle[:end]) ||
                               (subtitle[:end] > previous_subtitle[:start] &&
                                subtitle[:end] < previous_subtitle[:end]) ||
                               (previous_subtitle[:start] > subtitle[:start] &&
                                previous_subtitle[:start] < subtitle[:end]) ||
                               (previous_subtitle[:end] > subtitle[:start] &&
                                previous_subtitle[:end] < subtitle[:end]) ||
                               (subtitle[:start] == previous_subtitle[:start] ||
                                subtitle[:end] == previous_subtitle[:end])
          end
        end

        if collisions.to_f / have.subtitles.length.to_f > 0.01
          # Add a new track if there are > 1% collisions between these
          # subtitles and the ones that were last imported
          have.subtitles.each { |subtitle| subtitle[:track] = have.file }
        else
          # Otherwise continue using the previous track identifier
          # (= Assume that these and the previous subtitles are one track)
          previous_track = @haves[@haves.index(have) - 1].subtitles.first[:track]
          have.subtitles.each { |subtitle| subtitle[:track] = previous_track }
        end
      end
    end
Assigns track identification fields for distinguishing
 between continuous/simultaneous subtitles

 @params have [Have] What we {Have}