Equivalent Ruby code