maniacmusician
May 27th, 2007, 12:11 AM
As the title says.
I just started looking at ruby yesterday, and this is really my first serious attempt at learning anything coding-related (other than html/css).
So, I've learned that you can "load" certain files into a script, like you would load a CSS file from an html document, and this is done with the require 'script' method.
For some reason, this isn't working for me. it allows me to load things, but it doesn't recognize anything from the loaded content. For example, I wanted to do some file manipulation with my first ruby script. So, I looked in the documentation and found that the FileUtils class would be best suited for this. So, at the beginning of the script, I added
require 'fileutils'
which is supposed to load fileutils.rb. It seems to have worked in the sense that it doesn't return any errors (like it does when you try to load something that does not exist) but none of the methods work either. I have mkdir, cd, and cp in there. If I try, it gives me this feedback:
undefined method `cd' for main:Object (NoMethodError)
Which I find weird, because cd should be defined in FileUtils.
I've been following Why's poignant guide (I'm halfway through chapter 4), and when he used the wordlist.rb example and imported that, that didn't work for me either. I had to paste the code_words variable right into the main script to get it to recognize the variables.
So, what am I doing wrong?
Thanks.
edit: NEVERMIND I got it sorted out.
I just started looking at ruby yesterday, and this is really my first serious attempt at learning anything coding-related (other than html/css).
So, I've learned that you can "load" certain files into a script, like you would load a CSS file from an html document, and this is done with the require 'script' method.
For some reason, this isn't working for me. it allows me to load things, but it doesn't recognize anything from the loaded content. For example, I wanted to do some file manipulation with my first ruby script. So, I looked in the documentation and found that the FileUtils class would be best suited for this. So, at the beginning of the script, I added
require 'fileutils'
which is supposed to load fileutils.rb. It seems to have worked in the sense that it doesn't return any errors (like it does when you try to load something that does not exist) but none of the methods work either. I have mkdir, cd, and cp in there. If I try, it gives me this feedback:
undefined method `cd' for main:Object (NoMethodError)
Which I find weird, because cd should be defined in FileUtils.
I've been following Why's poignant guide (I'm halfway through chapter 4), and when he used the wordlist.rb example and imported that, that didn't work for me either. I had to paste the code_words variable right into the main script to get it to recognize the variables.
So, what am I doing wrong?
Thanks.
edit: NEVERMIND I got it sorted out.