# Store function output to string?

**URL:** <https://www.ruby-forum.com/t/store-function-output-to-string/99636>\
**Category:** Ruby\
**Created:** [July 24, 2006, 4:45pm UTC](https://www.ruby-forum.com/t/store-function-output-to-string/99636 "2006-07-24T16:45:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 24, 2006, 4:45pm UTC](https://www.ruby-forum.com/t/store-function-output-to-string/99636/1 "2006-07-24T16:45:55Z")

</div>

I am looking for a way to store a function’s output to a string.  
Believe it or not, I’ve had some trouble finding this using google.

I have a function for web testing (WET) that displays the text in an IE  
pop-up:

$ie.Dialog(“title:Window Title”).text()

This successfully prints the text of the pop-up in IRB. However, in  
order to validate this text, I want to capture it to a string, and then  
use a series of other strings to check it out.

How would I go about doing this?

Thanks.

irb(main):011:0\> ie.Dialog.text()  
=\> “There are problems with some of the form values:\n\n - email  
address is mi  
ssing.\n - your first and last names are required.\n - you must  
enter a comp  
any name.\n - you must enter a property name.\n - phone number is  
required.  
n”

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 24, 2006, 4:55pm UTC](https://www.ruby-forum.com/t/store-function-output-to-string/99636/2 "2006-07-24T16:55:25Z")

</div>

On 7/25/06, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> order to validate this text, I want to capture it to a string, and then  
> enter a comp  
> any name.\n - you must enter a property name.\n - phone number is  
> required.  
> n"

Since it’s returning a string in irb is it safe to assume

my\_string = ie.Dialog.text()  
?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 24, 2006, 5:28pm UTC](https://www.ruby-forum.com/t/store-function-output-to-string/99636/3 "2006-07-24T17:28:20Z")

</div>

Nevermind, got it.

alert = $ie.Dialog(“title:Window”).text().to\_s

So that’s how it works to store the output of a command rather than the  
command itself.
