librelist archives

« back to archive

Extending the Shoes classes

Extending the Shoes classes

From:
kwicher@wichry.net
Date:
2012-07-06 @ 20:35
Hi

How can I extend e.g. the Shoes::Stack class?
Something like that does not work on OSX 10.7.4:

class Shoes::Stack
 def label
   para "Stack" 
 end
end

Shoes.app do
 @s=stack :width=>200, :height=>200 do
  background red
 end
 @s.label
end

After running the application I get "undefined method 'label' for (Shoes::Stack)"

Thanks

K

Re: [shoes] Extending the Shoes classes

From:
Tobias Pfeiffer
Date:
2012-07-06 @ 20:44
Hi K,

why do you want to extend the stack class?

If I understand the intention of your code correctly the following would 
do the same:

Shoes.app do
   @s = stack width: 200, height: 200 do
     background red
     @label = para "Stack"
   end
end

Cheers,
Tobi

On 07/06/2012 10:35 PM, kwicher@wichry.net wrote:
> Hi
>
> How can I extend e.g. the Shoes::Stack class?
> Something like that does not work on OSX 10.7.4:
>
> class Shoes::Stack
>   def label
>     para "Stack"
>   end
> end
>
> Shoes.app do
>   @s=stack :width=>200, :height=>200 do
>    background red
>   end
>   @s.label
> end
>
> After running the application I get "undefined method 'label' for 
(Shoes::Stack)"
>
> Thanks
>
> K

Re: [shoes] Extending the Shoes classes

From:
kwicher@wichry.net
Date:
2012-07-06 @ 22:03
Thanks Tobi

Probably my example with "para" was not the most appropriate as obviously 
I could do it as you wrote.

However what if I would like to extend the class to have some other, not 
yet implemented functionality?

Best
krzys


On 6 Jul 2012, at 21:44, Tobias Pfeiffer wrote:

> Hi K,
> 
> why do you want to extend the stack class?
> 
> If I understand the intention of your code correctly the following would 
> do the same:
> 
> Shoes.app do
>   @s = stack width: 200, height: 200 do
>     background red
>     @label = para "Stack"
>   end
> end
> 
> Cheers,
> Tobi
> 
> On 07/06/2012 10:35 PM, kwicher@wichry.net wrote:
>> Hi
>> 
>> How can I extend e.g. the Shoes::Stack class?
>> Something like that does not work on OSX 10.7.4:
>> 
>> class Shoes::Stack
>>  def label
>>    para "Stack"
>>  end
>> end
>> 
>> Shoes.app do
>>  @s=stack :width=>200, :height=>200 do
>>   background red
>>  end
>>  @s.label
>> end
>> 
>> After running the application I get "undefined method 'label' for 
(Shoes::Stack)"
>> 
>> Thanks
>> 
>> K
> 

Re: [shoes] Extending the Shoes classes

From:
ashbb
Date:
2012-07-07 @ 00:25
Hi K, Tobi and folks,

In Shoes 3, you have to write the code like this to extend the Shoes
classes.

class Shoes::Types::Stack
  def label
    para "Stack"
  end
end

Ah,.. sorry don't ask me about `Types` for detail.

_why wrote a comment in the code:
https://github.com/shoes/shoes/blob/develop/shoes/ruby.c#L4353

But I think this is a bug. We should hide the Types module for users.

ashbb

Re: [shoes] Extending the Shoes classes

From:
kwicher@wichry.net
Date:
2012-07-07 @ 01:12
Thank you Satoshi

That is what I needed.

K
On 7 Jul 2012, at 01:25, ashbb wrote:

> Hi K, Tobi and folks,
> 
> In Shoes 3, you have to write the code like this to extend the Shoes classes.
> 
> class Shoes::Types::Stack
>   def label
>     para "Stack"
>   end
> end
> 
> Ah,.. sorry don't ask me about `Types` for detail.
> 
> _why wrote a comment in the code: 
https://github.com/shoes/shoes/blob/develop/shoes/ruby.c#L4353
> 
> But I think this is a bug. We should hide the Types module for users.
> 
> ashbb