Forum: Ruby Shoes GUI question - downloading body of sites using Ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Double M. (Guest)
on 2008-10-12 10:55
Hi all,


I want to use shoes to be able to download the body of a website that a
user enters in an edit_line.  How can I make this work?  Can anyone help
explain why the below code does not work?  It just pops up a new window,
and does not download the site from the text entered....

Here's my code thus far:

    Shoes.app do
      stack (:left => 175, :top => 200) do
        para "Enter a url:"
        flow do
          @url = edit_line
          button "OK" do

        window do
            stack do
             title "Searching site", :size => 16
              @status = para "One moment..."
               # Search site for query and print body
                download @url.text do |site|
                  @status.text = "Body: " + site.response.body.inspect
               end
            end
          end
        end
      end
    end
  end
_why (Guest)
on 2008-10-13 08:10
(Received via mailing list)
On Sun, Oct 12, 2008 at 03:52:58PM +0900, Double M. wrote:
> I want to use shoes to be able to download the body of a website that a
> user enters in an edit_line.  How can I make this work?

You're very, very close.  The problem is that instance variables
aren't shared between windows.  You can use a normal variable `url`
or, if you really need to use an instance variable, you can use
`owner.instance_variable_get("@url")` to get to it.

A good section to read in the docs is the "Block Redirection"
stuff, basically the first two sections on this page:
<http://help.shoooes.net/Rules.html>

_why
This topic is locked and can not be replied to.