Fix and validate ruby examples in API documentation (#587)
Merge review 371 by @wmrowan @al3xandru (Close #587)