Ruby implementation