# MacRuby Help

**URL:** <https://www.ruby-forum.com/t/macruby-help/163257>\
**Category:** Ruby\
**Created:** [March 18, 2009, 6:24pm UTC](https://www.ruby-forum.com/t/macruby-help/163257 "2009-03-18T18:24:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/97f17d/32.png) [@tomx](https://www.ruby-forum.com/u/tomx)\
**Post date:** [March 18, 2009, 6:24pm UTC](https://www.ruby-forum.com/t/macruby-help/163257/1 "2009-03-18T18:24:37Z")

</div>

I’m new to MacRuby and I was hoping to find anyone that could answer a  
question regarding it.

I’m able to make all sorts of function calls within OS X but I can’t  
seem to access the constants that are in the documentation. I want to  
access this enum (that I found in the OS X docs) in my macruby script:

enum CGPDFBox {  
kCGPDFMediaBox = 0,  
kCGPDFCropBox = 1,  
kCGPDFBleedBox = 2,  
kCGPDFTrimBox = 3,  
kCGPDFArtBox = 4  
};  
typedef enum CGPDFBox CGPDFBox;

I can call the CGPDFPageGetBoxRect just fine but macruby doesn’t know  
about the kCGPDFMediaBox enum I want to use while making that call. If I  
make the call like so:

mediaBounds = CGPDFPageGetBoxRect(page, kCGPDFMediaBox)

?\> mediaBounds = CGPDFPageGetBoxRect(page, kCGPDFMediaBox)  
NameError: undefined local variable or method `kCGPDFMediaBox' for main:NSObject from (irb):24 from /usr/local/bin/macirb:12:in`’

Can I use constants like this?

---

<div class="post-metadata">

**Author:** ![tomx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/97f17d/32.png) [@tomx](https://www.ruby-forum.com/u/tomx)\
**Post date:** [March 18, 2009, 7:36pm UTC](https://www.ruby-forum.com/t/macruby-help/163257/2 "2009-03-18T19:36:35Z")

</div>

Tom Santos wrote:

> I’m new to MacRuby and I was hoping to find anyone that could answer a  
> question regarding it.  
> […]  
> I can call the CGPDFPageGetBoxRect just fine but macruby doesn’t know  
> about the kCGPDFMediaBox enum I want to use while making that call. If I  
> make the call like so:

At a guess, you need to capitalise the first letter of the contant name,  
e.g. KCGPDFMediaBox.

HTH

## has

Control AppleScriptable applications from Python, Ruby and ObjC:  
[http://appscript.sourceforge.net](http://appscript.sourceforge.net)

---

<div class="post-metadata">

**Author:** ![tomx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/97f17d/32.png) [@tomx](https://www.ruby-forum.com/u/tomx)\
**Post date:** [March 18, 2009, 8:42pm UTC](https://www.ruby-forum.com/t/macruby-help/163257/3 "2009-03-18T20:42:31Z")

</div>

> At a guess, you need to capitalise the first letter of the contant name,  
> e.g. KCGPDFMediaBox.

That was it! Thanks much.
