[MacRuby-devel] looking for ruby-sher syntax

Eloy Duran eloy at dekleineprins.me
Fri Apr 1 05:54:54 PDT 2011


Code works for me, so it's not really clear to me which #transform
method you are missing. Regarding the style, I prefer to use
parenthesis, which makes it a bit clearer. If you really dislike it
and have to use it many times, you could of course wrap it:

$ macirb
irb(main):001:0> class NSAffineTransform
irb(main):002:1>   def translate(x, y)
irb(main):003:2>     translateXBy(x, yBy:y)
irb(main):004:1>   end
irb(main):005:0> end
=> nil
irb(main):006:0> transform = NSAffineTransform.transform
=> #<NSAffineTransform:0x20022c040>
irb(main):007:0> transform.translate(20, 20)
=> #<NSAffineTransform:0x20022c040>

Laurent: Coincidentally, I tried to alias translateXBy:yBy: to
translate, but when calling it it gives this error:

irb(main):013:0> transform.translate(20, 20)
ArgumentError: wrong number of arguments (2 for 2)

On Fri, Apr 1, 2011 at 1:29 PM, Thomas R. Koll <info at ananasblau.com> wrote:
> Hi,
>
> I just used a little transformation in a new game (pic [1], demo later)
> and wrote this which looks rubish and not so ruby-sh:
>
> transform = NSAffineTransform.transform
> transform.translateXBy 20, yBy: 20      # looks ugly
> transform.concat
>
> The MacRuby examples are all like this, and #translate doesn't exist,
> but I wonder if I missed something there?
>
>
> ciao, tom
>
> [1] https://skitch.com/tomk32/rahp3/sirtet
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>


More information about the MacRuby-devel mailing list