Need help Implementing DFS in Ruby

For sake of less text :