librelist archives

« back to archive

Sub classing . . .

Sub classing . . .

From:
Kc Erb
Date:
2014-01-19 @ 15:36
Hi all,

I'm trying out a new style!

Based on what I see in Nobody Knows Shoes, and in the class-book.rb sample
I think that the following should work:

https://gist.github.com/KCErb/8506417


But when I run it, I'm told that EQBuddy doesn't have a button method.

Feel free to explain even basic concepts in the answer. I've been playing
around with Shoes for months but I'm finding out that I still don't have a
good grasp on the basics of Ruby.

Thanks!

-KC

 "If there is an exception to every rule, then every rule must have at
least one exception; the exception to this one being that it has no
exception."

Re: [shoes] Sub classing . . .

From:
Eric Watson
Date:
2014-01-19 @ 16:09
On Jan 19, 2014, at 9:36 AM, KC Erb <iamkcerb@gmail.com> wrote:

> Hi all,
> 
> I'm trying out a new style! 
> 
> Based on what I see in Nobody Knows Shoes, and in the class-book.rb 
sample I think that the following should work:
> 
> https://gist.github.com/KCErb/8506417
> 
> 
> But when I run it, I'm told that EQBuddy doesn't have a button method. 

Here’s a version that works on Shoes 4 (on Shoes 3, it gives an 
UnboundMethod error…but I can’t get class-book.rb to work on my Shoes 3, 
either):

https://gist.github.com/wasnotrice/8506850

When you subclass Shoes, you can use the `url` class method to map Shoes 
urls to methods of your subclass. The normal Shoes code goes inside these 
methods, as you can see in the example. Hope that helps!

Eric

Re: [shoes] Sub classing . . .

From:
Kc Erb
Date:
2014-01-19 @ 19:29
That does help . . . but I don't get it yet :)

I guess I'm looking for a way to put a bunch of objects in my app which can
all use Shoes methods (stack, oval, etc.).  I thought the way to do that
was to make the objects inherit Shoes methods with the < symbol.

Now the impression I get, is that if I want an object to have Shoes methods
I need to use url . . . but that doesn't make sense yet.

Thanks for all the help you guys can give on this.





On Sun, Jan 19, 2014 at 9:09 AM, Eric Watson <wasnotrice@gmail.com> wrote:

>
> On Jan 19, 2014, at 9:36 AM, KC Erb <iamkcerb@gmail.com> wrote:
>
> > Hi all,
> >
> > I'm trying out a new style!
> >
> > Based on what I see in Nobody Knows Shoes, and in the class-book.rb
> sample I think that the following should work:
> >
> > https://gist.github.com/KCErb/8506417
> >
> >
> > But when I run it, I'm told that EQBuddy doesn't have a button method.
>
> Here’s a version that works on Shoes 4 (on Shoes 3, it gives an
> UnboundMethod error…but I can’t get class-book.rb to work on my Shoes 3,
> either):
>
> https://gist.github.com/wasnotrice/8506850
>
> When you subclass Shoes, you can use the `url` class method to map Shoes
> urls to methods of your subclass. The normal Shoes code goes inside these
> methods, as you can see in the example. Hope that helps!
>
> Eric
>
>


-- 
 "If there is an exception to every rule, then every rule must have at
least one exception; the exception to this one being that it has no
exception."

Re: [shoes] Sub classing . . .

From:
Tobias Pfeiffer
Date:
2014-01-19 @ 20:28
@Eric & UnboundedMethodError: afaik URLs are broken on OSX for shoes3

@KC: Subclassing shoes is somewhat weird behavior. It basically is the 
URL system. If you want to use shoes methods in other classes, the 
easiest thing to do (imo) is to pass around a reference to the 
Shoes::App object (self within the Shoes::App do ... end block) or a 
slot. In my pomodoro_tracker I initialize new object in a slot. To keep 
using shoes methods without calling them on the app object I use 
method_missing to forward the method calls to the app object, see here: 

https://github.com/PragTob/pomodoro_tracker/blob/master/lib/shoes_slot_manager/slot.rb#L26

Hope that helps!
Tobi

On Sun 19 Jan 2014 08:29:31 PM CET, KC Erb wrote:
> That does help . . . but I don't get it yet :)
>
> I guess I'm looking for a way to put a bunch of objects in my app
> which can all use Shoes methods (stack, oval, etc.).  I thought the
> way to do that was to make the objects inherit Shoes methods with the
> < symbol.
>
> Now the impression I get, is that if I want an object to have Shoes
> methods I need to use url . . . but that doesn't make sense yet.
>
> Thanks for all the help you guys can give on this.
>
>
>
>
>
> On Sun, Jan 19, 2014 at 9:09 AM, Eric Watson <wasnotrice@gmail.com
> <mailto:wasnotrice@gmail.com>> wrote:
>
>
>     On Jan 19, 2014, at 9:36 AM, KC Erb <iamkcerb@gmail.com
>     <mailto:iamkcerb@gmail.com>> wrote:
>
>     > Hi all,
>     >
>     > I'm trying out a new style!
>     >
>     > Based on what I see in Nobody Knows Shoes, and in the
>     class-book.rb sample I think that the following should work:
>     >
>     > https://gist.github.com/KCErb/8506417
>     >
>     >
>     > But when I run it, I'm told that EQBuddy doesn't have a button
>     method.
>
>     Here’s a version that works on Shoes 4 (on Shoes 3, it gives an
>     UnboundMethod error…but I can’t get class-book.rb to work on my
>     Shoes 3, either):
>
>     https://gist.github.com/wasnotrice/8506850
>
>     When you subclass Shoes, you can use the `url` class method to map
>     Shoes urls to methods of your subclass. The normal Shoes code goes
>     inside these methods, as you can see in the example. Hope that helps!
>
>     Eric
>
>
>
>
> --
>  "If there is an exception to every rule, then every rule must have at
> least one exception; the exception to this one being that it has no
> exception."