Ruby Plasma Tutorial

Richard Dale richard.j.dale at gmail.com
Mon Jan 19 15:33:56 CET 2009


2009/1/18 Niels Slot <nielsslot at gmail.com>

> In the last week I've written a Plasma tutorial for Ruby. In the tutorial
> the reader creates a simple but functional applet using widgets and Ruby.
> I've put it on a personal subpage on Techbase[1]. I would like to ask for
> some feedback. I've got one and a half years of Ruby experience, but I'm
> quite new with programming Plasma.
>
> I've also seen the new Python tutorial, they look really nice. I'd be
> willing to help 'translate' these to Ruby. When doing this, it would be nice
> to have a way to share some pieces of the Python tutorials. The parts about,
> for example, installing plasmoids, metadata.desktop and using the
> eningeexplorer, are the same for any scripting language. Can we come up with
> some way to share these texts while not confusing the reader?
>
> Niels
>
> 1: http://techbase.kde.org/User:Nielsslot/RubyPlasmaTutorial
>
That looks excellent to me. As well as a tutorial you've added some Ruby
basics stuff so it will make sense to Ruby beginners.

 I have a couple of comments about the example code.

 Firstly, I think the main class doesn't have to be called 'Main' anymore,
and if your X-Plasma-MainScript has a value of code/foo_bar_baz.rb you
should be able to use a class called 'FooBarBaz'. I haven't actually tried
that yet, but if it doesn't work that is a bug.

Secondly you shouldn't need to call methods on @parent.applet explicitely
because the PlasmaScripting::Applet class uses method_missing() to forward
any calls it can't handle to the underlying @parent.applet. So if you
reference 'layout()' and your applet doesn't implement that, the call will
automatically be forwarded to @parent.applet. Setters like 'self.layout =
my_layout' or 'setLayout(my_layout)' should also work.

-- Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/plasma-devel/attachments/20090119/0232bd08/attachment.htm 


More information about the Plasma-devel mailing list