source: libcaca/trunk/ruby/ruby-caca.dox @ 2077

Last change on this file since 2077 was 2077, checked in by Pascal Terjan, 13 years ago
  • Add Caca.version and Cucul.version
File size: 2.0 KB
Line 
1/* $Id$ */ /** \page libcaca-ruby-api Libcaca Ruby API
2
3The classes available for libcaca are :
4
5\li \b Caca::Display
6\li \b Caca::Event
7\li \b Caca::Event::Key
8\li \b Caca::Event::Key::Press
9\li \b Caca::Event::Key::Release
10\li \b Caca::Event::Mouse
11\li \b Caca::Event::Mouse::Press
12\li \b Caca::Event::Mouse::Release
13\li \b Caca::Event::Mouse::Motion
14\li \b Caca::Event::Resize
15\li \b Caca::Event::Quit
16
17\code
18$ irb -rcaca
19irb(main):001:0> class Object
20irb(main):002:1>   def Object.my_instance_methods
21irb(main):003:2>     instance_methods.sort - ancestors[1].instance_methods
22irb(main):004:2>   end
23irb(main):005:1>   def Object.my_methods
24irb(main):006:2>     methods.sort - ancestors[1].methods
25irb(main):007:2>   end
26irb(main):008:1> end
27\endcode
28
29\code
30irb(main):009:0> Caca.my_methods
31=> ["version"]
32\endcode
33
34\code
35irb(main):010:0> Caca::Display.my_instance_methods
36=> ["get_event", "height", "mouse=", "mouse_x", "mouse_y", "refresh",
37"set_mouse", "set_time", "set_title", "time", "time=", "title=", "width"]
38\endcode
39
40\code
41irb(main):011:0> Caca::Event.constants
42=> ["Key", "Quit", "TYPE", "Mouse", "Resize"]
43\endcode
44
45\code
46irb(main):012:0> Caca::Event.my_instance_methods
47=> ["quit?"]
48\endcode
49
50\code
51irb(main):013:0> Caca::Event::Key.my_instance_methods
52=> ["ch", "utf32", "utf8"]
53\endcode
54
55\code
56irb(main):014:0> Caca::Event::Mouse.my_instance_methods
57=> ["button", "x", "y"]
58\endcode
59
60\code
61irb(main):015:0> Caca::Event::Resize.my_instance_methods
62=> ["w", "h"]
63\endcode
64
65\section Samples
66
67\code
68require 'caca'
69c = Cucul::Canvas.new(20,10)
70c.put_str(2, 3, "plop!")
71c.draw_thin_polyline([[0,0], [0,2], [5,2], [0,0]])
72d = Caca::Display.new(c)
73d.title = "Test !"
74d.refresh
75
76# Redefine Event::Key#quit? so that q, Q, and Esc become exit keys
77module Caca
78        class Event::Key
79                def quit?
80                        "qQ^[".split('').member?(@ch.chr)
81                end
82        end
83end
84
85while((e = d.get_event(Caca::Event, -1)) && ! e.quit?)
86    p e
87    d.refresh
88end
89\endcode
90
91*/
Note: See TracBrowser for help on using the repository browser.