Forum: Ruby MacRuby Help

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
72d846151cb2807e7454f5be368bd980?d=identicon&s=25 Tom Santos (zonkhead)
on 2009-03-18 18:24
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 `<main>'

Can I use constants like this?
6bdc6b64f46bbb6dd6e84b5ba68385fc?d=identicon&s=25 hengist podd (has)
on 2009-03-18 19:36
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
72d846151cb2807e7454f5be368bd980?d=identicon&s=25 Tom Santos (zonkhead)
on 2009-03-18 20:42
> At a guess, you need to capitalise the first letter of the contant name,
> e.g. KCGPDFMediaBox.

That was it!  Thanks much.
This topic is locked and can not be replied to.