Added attr_accessor and changed puts to return

The reason it worked in the terminal was because you wrote "puts". Puts simply prints to the terminal. You want your function to return that string. Technically, I don't need to write "return" because ruby automatically returns the last line of a function but I am writing it explicitly because I found it helpful when I started learning. 

Every method in ruby returns a value by default. 

I think the second response to this question might clear things up - http://stackoverflow.com/questions/1023146/is-it-good-style-to-explicitly-return-in-ruby

Let me know if you have any questions.