0

I was wondering how to load a file from my System Libraries, but I'm not sure how. I was thinking something along the lines of:

require 'gosu' require "Picture.jpg" 

and then having the rest of my code, but every time I try that, I get the error:

No such file to load 

I'm not sure if I'm doing something wrong, or there just isn't a way to load a file from my system library into Ruby?

3
  • 2
    Require is only for ruby code - requiring a jpg won't ever work Commented Apr 28, 2013 at 14:51
  • Is "Picture.jpg" a file written in Ruby? Commented Apr 28, 2013 at 17:36
  • 2
    What are you trying to accomplish by loading "Picture.jpg"? require will read a system file or a gem, which consist of Ruby code. Ruby would have no idea what to do with a binary "jpg" file and would raise an error immediately. It's possible to tell Ruby to read a binary file into a variable for processing in some way, but unless we know what you intend to do with it we won't be able to help you further. Commented Apr 29, 2013 at 1:44

1 Answer 1

1

I would suggest you to take close looks at require, load, extend and include.

It will help you to use in your application.

http://ionrails.com/2009/09/19/ruby_require-vs-load-vs-include-vs-extend/

Sign up to request clarification or add additional context in comments.

1 Comment

thetinman, i didn't acutally mean to load a jpg file. I was just giving an example of a random name of a file for the coding. I have a lot of files in my system, and I just didn't feel like digging through all my files. frederick and saws, u r right but again, not a real file i have.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.