linked list cyclic? method implemented in ruby