The basic idea is that you bundle a browser, and then using your programming language of choice, you can create APIs that are available inside JavaScript.
So, you can also probably create functionality in ruby, that can then be accessed in JavaScript.