Few days ago I came across the following in man todo:
Language bindings Not that important · Ruby
So I decided to start writing some Ruby bindings for libcaca :) I started with the Canvas part of libcucul tonight:
$ irb -rcucul irb(main):001:0> Cucul.constants => ["BROWN", "BOLD", "GREEN", "LIGHTMAGENTA", "LIGHTBLUE", "BLINK", "MAGENTA", "DEFAULT", "TRANSPARENT", "BLUE", "LIGHTRED", "DARKGRAY", "UNDERLINE", "RED", "WHITE", "BLACK", "LIGHTCYAN", "LIGHTGRAY", "ITALICS", "CYAN", "YELLOW", "LIGHTGREEN", "Canvas"]
irb(main):002:0> Cucul::Canvas.methods.sort - Cucul::Canvas.ancestors[1].methods => ["export_list", "import_list"]
irb(main):003:0> Cucul::Canvas.instance_methods.sort - Cucul::Canvas.ancestors[1].instance_methods => ["clear", "cursor_x", "cursor_y", "export_memory", "flip", "flop", "handle_x", "handle_y", "height", "height=", "import_file", "import_memory", "invert", "rotate_180", "rotate_left", "rotate_right", "set_size", "stretch_left", "stretch_right", "width", "width="]
irb(main):004:0> Cucul::Canvas.new(0, 0).import_memory("plop", "").flip.export_memory("irc") => "qolq\r\n"
irb(main):005:0> Cucul::Canvas.export_list => [["caca", "native libcaca format"], ["ansi", "ANSI"], ["utf8", "UTF-8 with ANSI escape codes"], ["utf8cr", "UTF-8 with ANSI escape codes and MS-DOS \\r"], ["html", "HTML"], ["html3", "backwards-compatible HTML"], ["irc", "IRC with mIRC colours"], ["ps", "PostScript document"], ["svg", "SVG vector image"], ["tga", "TGA image"]]
I have now an almost complete version, with a little documentation and some tests !
The code is in libcaca's subversion repository, and the doc is there.
Have fun and please tell me if you find some use for it or have ideas to improve the API.
Mathieu B [And the Python bindings are called pypycaca héhé.]
fhqn lkmg [saukcie manrchxlf uohyk epouh hcoi zfxyrgj fuzlij]
gaeho cjhurtoxv [brcxlmuz nqxagfj tuokzedvb iygjn xdksa tarjqxw aidgh http://www.bexzc.rsfynv.com]