Make ruby code idiomatic

Convert the existing Ruby code to be more idiomatic