Ignore:
Timestamp:
Nov 25, 2007, 10:48:30 AM (12 years ago)
Author:
Pascal Terjan
Message:
  • Little improvements in ruby doc + Made the doc a little more easy to read + Added an example on a nice way to have q, Q and Esc to cause exit
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/ruby/ruby-caca.dox

    r2042 r2048  
    1616
    1717\code
    18 irb(main):007:0> Caca::Display.instance_methods.sort -
    19 Caca::Display.ancestors[1].instance_methods
     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
     28irb(main):009:0> Caca::Display.my_instance_methods
    2029=> ["get_event", "height", "mouse=", "mouse_x", "mouse_y", "refresh",
    2130"set_mouse", "set_time", "set_title", "time", "time=", "title=", "width"]
     
    2332
    2433\code
    25 irb(main):008:0> Caca::Event.constants
     34irb(main):010:0> Caca::Event.constants
    2635=> ["Key", "Quit", "TYPE", "Mouse", "Resize"]
    2736\endcode
    2837
    2938\code
    30 irb(main):009:0> Caca::Event::Key.instance_methods - Caca::Event::Key.ancestors[1].instance_methods
     39irb(main):011:0> Caca::Event.my_instance_methods
     40=> ["quit?"]
     41\endcode
     42
     43\code
     44irb(main):012:0> Caca::Event::Key.my_instance_methods
    3145=> ["ch", "utf32", "utf8"]
    3246\endcode
    3347
    3448\code
    35 irb(main):010:0> Caca::Event::Key.instance_methods - Caca::Event::Mouse.ancestors[1].instance_methods
    36 => ["ch", "utf32", "utf8"]
    37 \endcode
    38 
    39 \code
    40 irb(main):011:0> Caca::Event::Mouse.instance_methods - Caca::Event::Mouse.ancestors[1].instance_methods
     49irb(main):013:0> Caca::Event::Mouse.my_instance_methods
    4150=> ["button", "x", "y"]
    4251\endcode
    4352
    4453\code
    45 irb(main):018:0> Caca::Event::Resize.instance_methods - Caca::Event::Resize.ancestors[1].instance_methods
     54irb(main):014:0> Caca::Event::Resize.my_instance_methods
    4655=> ["w", "h"]
    4756\endcode
     
    5766d.title = "Test !"
    5867d.refresh
     68
     69# Redefine Event::Key#quit? so that q, Q, and Esc become exit keys
     70module Caca
     71        class Event::Key
     72                def quit?
     73                        "qQ^[".split('').member?(@ch.chr)
     74                end
     75        end
     76end
     77
    5978while((e = d.get_event(Caca::Event, -1)) && ! e.quit?)
    6079    p e
Note: See TracChangeset for help on using the changeset viewer.