[Wtr-development] element.to_s instead of element.show
Bret Pettichord
bret at pettichord.com
Sat Oct 2 13:43:29 EDT 2010
Alan,
What you are are really asking for is useful "inspect" methods. This is what
IRB uses by default to display an object.
I believe someone fairly recently cleaned these up. Could you take a look at
them and let us know if these meet your needs? If not, I'd like to make them
better.
Bret
On Fri, Oct 1, 2010 at 9:52 PM, Alan Baird <abaird at bairdsnet.net> wrote:
> >The show methods were quite handy before there were tools like firebug.
> Now I never use them any more. Does any one?
>
> I don't use the show methods, but the .to_s methods come in handy. Here is
> my use case. Suppose you need to get some specific divs and you do
> something like:
>
> important_divs = @br.divs.select{|div|
> div.class_name[/important_div_regexp/]}
>
> Now, if I'm in irb, I might test this out to see if the important_divs are
> really the ones I'm looking for, and the implementation of .to_s currently
> lists the id and other important attributes. It's not clear in your
> proposal if this would stop working like this and instead I would get the
> normal ruby class name syntax. If this is the case, this would be less
> functional and would cause me to do more work to iterate through
> important_divs to check them out and see if they were what I wanted. IE Dev
> toolbar and Firefox don't help here because I'm using it to debug my program
> in irb.
>
> We don't have to do any work to keep the .to_s methods do we? If not, why
> should we remove them if they are useful for some and not harmful to others?
>
> Alan
>
> _______________________________________________
> Wtr-development mailing list
> Wtr-development at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-development
>
--
Bret Pettichord
Lead Developer, Watir, www.watir.com
Blog, www.io.com/~wazmo/blog
Twitter, www.twitter.com/bpettichord
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/wtr-development/attachments/20101002/0e2fb8e8/attachment.html>
More information about the Wtr-development
mailing list