Generating a List of Substrings

Here is one way to generate a list of unique substrings from a string.

def substrings_generator(string)
  substrings_list = []

  0.upto(string.size) do |start_index|
    (start_index + 1).upto(string.size) do |end_index|
      substrings_list << string.slice(start_index, end_index)
      substrings_list
    end
  end

  substrings_list.uniq
end