Using `yes` you would do:
yes "\n" | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
i.e. you need to supply a newline rather than the character y. You can also do:
CI=TRUE ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Which is probably the more correct way. It does require you know the CI flag exists and that the script respects it, but CI is a pretty common env var these days, a defacto standard, and is generally scrips that can be run interactively but which you might want to implore to just do whatever they're supposed to do will respect it.