Ruby logical programming