Fix and validate ruby examples in API documentation (#587)