Hi Jean,

On Aug 20, 2008, at 4:59 PM, Jean Lazarou wrote:

Hi Ernest,

Where does the '$app' come from?

That's just a global that you initialize from *inside* the 'Shoes.app' section of your code, so you can refer to it elsewhere.

Look at some of the examples, like tankspank.

-enp



-Jean


On Wed, Aug 20, 2008 at 11:26 PM, Ernest Prabhakar <[EMAIL PROTECTED] > wrote:
Hi Jean,

You may want to try the:

$app = self
$app.draw_background

trick....

-enp



On Aug 20, 2008, at 11:22 AM, Jean Lazarou wrote:

Thank you all for answering, but if I go for simplicity nothing works...

34 Shoes.app :height => 260, :width => 250 do
35   animate(1) do
36     @time = Time.now
37     clear do
38       draw_background
39       stack do
40         puts "Time = [EMAIL PROTECTED]"
41       end
42     end
43   end
44   def draw_background
45     puts "draw_background"
46   end
47 end

If I define a Shoes class as following and some methods (like animate):

13 class Shoes
14
15    def self.app params
16      yield
17    end
18
19
20 end
21
22  def animate fps, &block
23    yield
24  end
25
26  def clear
27    yield
28  end
29
30  def stack
31    yield
32  end

I get

test.rb:38: undefined local variable or method `draw_background' for #<Object:0x288fa34 @time=Wed Aug 20 19:56:46 +0200 2008> (NameError)
   from test.rb:27:in `clear'

I don't find any easy way to make the code run. Of course, if I comment the call to `draw_background' (line 38) I get the output => Time = Wed Aug 20 20:03:22 +0200 2008

(I run the code with the C-Ruby runtime)

Is there some Ruby technical I don't know?

Jean




Reply via email to