# RubyCocoa question

**URL:** <https://www.ruby-forum.com/t/rubycocoa-question/48126>\
**Category:** Ruby\
**Created:** [November 16, 2005, 11:41pm UTC](https://www.ruby-forum.com/t/rubycocoa-question/48126 "2005-11-16T23:41:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ezra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/d07c76/32.png) [@ezra](https://www.ruby-forum.com/u/ezra)\
**Post date:** [November 16, 2005, 11:41pm UTC](https://www.ruby-forum.com/t/rubycocoa-question/48126/1 "2005-11-16T23:41:25Z")

</div>

Hey list-

Does anyone have an example of using rubycocoa to create a simple  
app that can display a file open dialog or sheet and then return a  
stirng of the file path to ruby so I can do some text processing on  
it? I would really appreciate some pointers. I couldn’t find anything  
that deals with files in the sample programs.

Thanks-

-Ezra Z.  
Yakima Herald-Republic  
WebMaster

> **[yakimaherald.com | Yakima, Washington - We Tell Your Stories](https://www.yakimaherald.com/)**

509-577-7732  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![ezra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/d07c76/32.png) [@ezra](https://www.ruby-forum.com/u/ezra)\
**Post date:** [November 17, 2005, 6:34am UTC](https://www.ruby-forum.com/t/rubycocoa-question/48126/2 "2005-11-17T06:34:23Z")

</div>

On Nov 16, 2005, at 5:39 PM, Ezra Z. wrote:

> -Ezra Z.  
> Yakima Herald-Republic

See the NSOpenPanel documentation. I haven’t used RubyCocoa much but  
I would imagine it would look like

require ‘osx/cocoa’

opanel = OSX::NSOpenPanel.openPanel  
opanel.runModalForDirectory\_file\_types\_(nil, nil, nil)  
results = opanel.URLs

---

<div class="post-metadata">

**Author:** ![ezra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/d07c76/32.png) [@ezra](https://www.ruby-forum.com/u/ezra)\
**Post date:** [November 17, 2005, 2:03pm UTC](https://www.ruby-forum.com/t/rubycocoa-question/48126/3 "2005-11-17T14:03:55Z")

</div>

> **[Radar - O’Reilly](https://www.oreilly.com/radar/)**
>
> Now, next, and beyond: Tracking need-to-know trends at the intersection of business and technology

see def addFile

the whole thing can be downloaded (see end of tutorial) so you can see  
how it works.

---

<div class="post-metadata">

**Author:** ![ezra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/d07c76/32.png) [@ezra](https://www.ruby-forum.com/u/ezra)\
**Post date:** [November 18, 2005, 8:38pm UTC](https://www.ruby-forum.com/t/rubycocoa-question/48126/4 "2005-11-18T20:38:50Z")

</div>

anne001 wrote:

> [Radar – O’Reilly](http://www.macdevcenter.com/pub/a/mac/2004/10/12/cocoa.html)
> 
> see def addFile
> 
> the whole thing can be downloaded (see end of tutorial) so you can see  
> how it works.

Note that that particular demo (a GUI to the tar comamnd) is missing one  
step of configuration.  
You need to connect the NSTableView to the Controller Instance using the  
dataSource outlet from the NSTableView.  
J-P

---

<div class="post-metadata">

**Author:** ![ezra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/d07c76/32.png) [@ezra](https://www.ruby-forum.com/u/ezra)\
**Post date:** [November 18, 2005, 9:24pm UTC](https://www.ruby-forum.com/t/rubycocoa-question/48126/5 "2005-11-18T21:24:08Z")

</div>

On 11/18/05, Ezra Z. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Note that that particular demo (a GUI to the tar comamnd) is  
> > and running with the app I needed to create. RubyCocoa is very cool.
> 
> I have one more question about rubycocoa. Is there any way to bundle  
> a ruby interpreter inside the .app bundle so my app can run on  
> another OS X machine without ruby installer? Is there a built in way  
> to do this with rubycocoa? Or would rubyscript2exe work to do this  
> somehow?
> 
> Thanks for any feedback-

This is just wild speculation but you could build a prefix’d install of  
ruby  
and rubycocoa on your machine, and put it into your app bundle. Then  
write a  
little shell script that launches ruby and your script and use that as  
what  
the bundle calls to start your app. Again, I haven’t actually TRIED this  
approach, but in theory it should work 🙂

Cheers-

---

<div class="post-metadata">

**Author:** ![ezra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/d07c76/32.png) [@ezra](https://www.ruby-forum.com/u/ezra)\
**Post date:** [November 18, 2005, 9:18pm UTC](https://www.ruby-forum.com/t/rubycocoa-question/48126/6 "2005-11-18T21:18:06Z")

</div>

On Nov 18, 2005, at 11:37 AM, Jaypee wrote:

> dataSource outlet from the NSTableView.  
> J-P

```
Thanks for the help to everyone who replied. I was able to get up

```

and running with the app I needed to create. RubyCocoa is very cool.

```
I have one more question about rubycocoa. Is there any way to bundle

```

a ruby interpreter inside the .app bundle so my app can run on  
another OS X machine without ruby installer? Is there a built in way  
to do this with rubycocoa? Or would rubyscript2exe work to do this  
somehow?

Thanks for any feedback-

Cheers-

-Ezra Z.  
Yakima Herald-Republic  
WebMaster

> **[yakimaherald.com | Yakima, Washington - We Tell Your Stories](https://www.yakimaherald.com/)**

509-577-7732  
removed\_email\_address@domain.invalid
