def merge(tab)
      raise ArgumentError, 'Only tables could be merged' unless tab.is_a?(self.class)
      raise ArgumentError, 'Primary keys not the same' unless tab.primary_key == primary_key

      # Empty content
      content = []
      row_keys = (@row_keys.keys | tab.row_keys).map.with_index { |row, i| [row, i] }.to_h
      col_keys = (@col_keys.keys | tab.col_keys).map.with_index { |col, i| [col, i] }.to_h
      row_keys.size.times { content << Array.new(col_keys.size, '') }

      # rubocop:disable Lint/Eval, Style/SpaceInsideStringInterpolation

      # Fill content with self
      eval <<-END_OF_DOC
        @row_keys.each do |row, old_ri|
          new_ri = row_keys[row]
          #{
            str = []
            @col_keys.map do |col, old_ci|
              new_ci = col_keys[col]
              str << "content[new_ri][#{new_ci}] = @content[old_ri][#{old_ci}]"
            end
            str.join("\n" + ' ' * 8)
          }
        end
      END_OF_DOC

      # Fill content with tab
      @content_merged_with = tab.instance_variable_get(:@content)
      eval <<-END_OF_DOC
        tab.row_keys.each_with_index do |row, old_ri|
          new_ri = row_keys[row]
          #{
            str = []
            tab.col_keys.each_with_index do |col, old_ci|
              new_ci = col_keys[col]
              str << "content[new_ri][#{new_ci}] = @content_merged_with[old_ri][#{old_ci}]"
            end
            str.join("\n" + ' ' * 8)
          }
        end
      END_OF_DOC

      # rubocop:enable Lint/Eval, Style/SpaceInsideStringInterpolation, Lint/UselessAssignment

      # Create a new table
      self.class.build(
        primary_key: primary_key,
        row_keys: row_keys,
        col_keys: col_keys,
        content: content,
        comments: comments + tab.comments
      )
    end
def merge(tab)
      raise ArgumentError, 'Only tables could be merged' unless tab.is_a?(self.class)
      raise ArgumentError, 'Primary keys not the same' unless tab.primary_key == primary_key

      # Empty content
      content = []
      row_keys = (@row_keys.keys | tab.row_keys).map.with_index { |row, i| [row, i] }.to_h
      col_keys = (@col_keys.keys | tab.col_keys).map.with_index { |col, i| [col, i] }.to_h
      row_keys.size.times { content << Array.new(col_keys.size, '') }

      # rubocop:disable Lint/Eval, Style/SpaceInsideStringInterpolation

      # Fill content with self
      eval <<-END_OF_DOC
        @row_keys.each do |row, old_ri|
          new_ri = row_keys[row]
          #{
            str = []
            @col_keys.map do |col, old_ci|
              new_ci = col_keys[col]
              str << "content[new_ri][#{new_ci}] = @content[old_ri][#{old_ci}]"
            end
            str.join("\n" + ' ' * 8)
          }
        end
      END_OF_DOC

      # Fill content with tab
      @content_merged_with = tab.instance_variable_get(:@content)
      eval <<-END_OF_DOC
        tab.row_keys.each_with_index do |row, old_ri|
          new_ri = row_keys[row]
          #{
            str = []
            tab.col_keys.each_with_index do |col, old_ci|
              new_ci = col_keys[col]
              str << "content[new_ri][#{new_ci}] = @content_merged_with[old_ri][#{old_ci}]"
            end
            str.join("\n" + ' ' * 8)
          }
        end
      END_OF_DOC

      # rubocop:enable Lint/Eval, Style/SpaceInsideStringInterpolation, Lint/UselessAssignment

      # Create a new table
      self.class.build(
        primary_key: primary_key,
        row_keys: row_keys,
        col_keys: col_keys,
        content: content,
        comments: comments + tab.comments
      )
    end
Merge with another table
 @param tab [Table]