Shoes.app do
  @originals =
    ['be', 'from', 'be-cause', 'here', 'over', 'saw', 'again', 'friend']

  def shuffle
    @words = @originals.map {|x| [rand, x]}.sort.map {|r, x| x}
  end
  
  def choose_word
    shuffle if !@words || @words.empty?

    @title.replace 'Spell this word'
    @word = @words.pop
  end
  
  @title = title ''

  flow do
    @say = button 'Say it'
    @show = button 'Show it'
    @next = button 'Next word'
  end

  @say.click {`osascript -e 'say "#{@word}"'`}
  @show.click {@title.replace @word.gsub('-', '')}
  @next.click {choose_word}
  
  choose_word
end
