Currently the most mature client library for Ruby is the synchronous ruby-mqtt , the async em-mqtt has yet to support user/password before it's usable with CloudMQTT.
The full source for the example can be found here: https://github.com/CloudMQTT/ruby-mqtt-example
Worth noting is that the client does not yet support other QoS levels than 0, ie. no publish acknowledge or redelivery.