Search code examples
rubyfxruby

How do I fetch images of the internet in FXRuby?


so let me preface this with the fact that I am a beginner at ruby and FXruby. I would like to know how I can fetch images by using a URL. This is the code I used when getting them off my desktop:

require 'rubygems'

require 'fox16'

include Fox


class Image_Viewer <FXMainWindow
  def initialize(app)
    super(app, "Image Viewer", :opts => DECOR_ALL, :width => 500, :height => 450) 
    @pic = File.open("/Users/AdamAshwal/Desktop/image.jpg", "rb")
    @pic2 = FXJPGImage.new(app, @pic.read)
    FXImageFrame.new(self, @pic2)

end 
  def create
    super
    self.show(PLACEMENT_SCREEN)
end

end


app = FXApp.new
mainwin = Image_Viewer.new(app)

app.create
app.run

Solution

  • That should be

    require 'open-uri'
    

    and not

    require 'open-url'