refactored logic out of graph generator specific to rubys s-exp, added test cases for this