Unespected keyword_end Ruby

0

I was converting a QuickSort algorithm I did in java to ruby when I get the following error:

  

unespected keyword_end

As I know, this error appears when there is no end in the code, the problem is that I just can not identify where it's missing, I already tried to close the code blocks in VsCode to try to find the error , but I just do not identify them.

By command:

  

ruby -w start.rb

I received the following result:

./src/QuickSortAnalysis.rb:67: warning: mismatched indentations at 'end' with 'if' at 55
./src/QuickSortAnalysis.rb:80: warning: mismatched indentations at 'end' with 'while' at 75
./src/QuickSortAnalysis.rb:81: warning: mismatched indentations at 'end' with 'def' at 69

But for me the result still seems meaningless, it follows the code:

require './src/TableAnalysis.rb'
require './src/UserInfo.rb'
require './src/InvalidParameterException.rb'

# Classe para ordenacao quickSort
# @see TableAnalysis
class QuickSortAnalysis 
    include TableAnalysis

    # Realiza uma analise ordenacao quickSort
    # @param userInfoList Lista de dados a ser analisada
    # @return Elemento aleatorio da lista
    # @see TableAnalysis
    def analysis(userInfoList)
        validation = (userInfoList.nil? || userInfoList.size == 0)
        raise InvalidParameterException.new("'userInfoList' é nil ou vazio") if(validation)

        @arrayUserInfo = userInfoList

        quickSort(0, @arrayUserInfo.length - 1)

        return @arrayUserInfo;
    end

    private
    # Iniciando quickSort
    # @param baixo index inicial
    # @param alto index final
    def quickSort(baixo, alto)
        raise InvalidParameterException.new("'baixo' é maior que 'alto'") if (baixo > alto)

        indexInicio, indexFim = baixo, alto

        # Get the pivot element from the middle of the list
        index = baixo + (alto - baixo)/2 
        indexPivot = index.round

        # Divide into two lists
        while indexInicio <= indexFim


            # If the current value from the left list is smaller than the pivot
            # element then get the next element from the left list
            indexInicio = self.findIndex(indexPivot, indexInicio)

            # If the current value from the right list is larger than the pivot
            # element then get the next element from the right list
            indexFim = self.findIndex(indexPivot, indexFim)

            # If we have found a value in the left list which is larger than
            # the pivot element and If we have found a value in the right list
            # which is smaller than the pivot element then we exchange the
            # values.
            # As we are done we can increase i and j
            if indexInicio <= indexFim
                @arrayUserInfo[indexInicio], @arrayUserInfo[indexFim] = @arrayUserInfo[indexFim], @arrayUserInfo[indexInicio]

                indexInicio++
                indexFim--
            end

        end

        # Recursion
        self.quickSort(baixo, indexFim) if (baixo < indexFim)
        self.quickSort(indexInicio, alto) if (indexInicio < alto)
    end

    def findIndex(indexPivot, indexMatch)

        pivotCredit = @arrayUserInfo[indexPivot].getCredit

        # If the current value from the left list is smaller than the pivot
        # element then get the next element from the left list
        while @arrayUserInfo[indexMatch].getCredit < pivotCredit
            indexMatch++
        end

        return indexMatch
    end
end

Could anyone tell me what I'm letting go unnoticed?

    
asked by anonymous 05.04.2018 / 21:43

0 answers