Your question is "Why" but the answer posted is "How".

I don't know "Who" down-voted you which is the only definitive way of finding out "why" because we can ask him or her.

I suspect the reason is they felt you were looking for someone to debug your script for you and/or they had little appreciation of ruby. Personally I skip over questions where I know nothi8ng about them.

As for your question itself you might want to consider something other than `pactl` because I've had problems with it setting the volume accurately myself. If you read this: [https://askubuntu.com/questions/97936/terminal-command-to-set-audio-volume][1] there are other options available.

Consolation prize: I'm up-voting your question here in meta :)


  [1]: https://askubuntu.com/questions/97936/terminal-command-to-set-audio-volume