From: Bob Hutchison Date: 2008-03-15T23:17:25+09:00 Subject: Re: baffling undefined method error - addendum On 15-Mar-08, at 9:33 AM, Tom Cloyd wrote: > Tom Cloyd wrote: >> I'm getting an error I can't account for. In a method I've written >> I open a file and access a yaml store: >> >> archive_stored_list = 'archive_stored_list.yml' >> archives_stored_catalog = File.open(archive_stored_list) {|i| >> YAML.load(i)} >> >> I massage the data a bit, and want to write it back out to the same >> file. I try to close the file so I can open it for output, but get >> an error: >> >> archives_stored_catalog.close # <= "undefined method `close'" error >> is written to log file here >> open(archive_stored_list,"w") {|i| >> YAML.dump(archives_stored_catalog,i)} >> >> Why is this giving an error? Isn't the IO.close method always >> available? Very confusing. >> >> This usage is straight out of Programming Ruby 2nd edition, but it >> doesn't work for me, and I can't see the error. >> >> Would appreciate any help. >> >> Tom >> > If I do NOT try to close the file (and in all the examples I've > found, this isn't done - I just see an open to read, followed by > another open to write), I get a "Permission denied - > archive_stored_list.yml" message. That makes no sense. There CAN'T > be a permission problem. I just READ the file. > > I await higher wisdom. Don't count on it from me, but do you have write permission on the file? Cheers, Bob > > t. > > -- > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Tom Cloyd, MS MA, LMHC > Private practice Psychotherapist > Bellingham, Washington, U.S.A: (360) 920-1226 > << tc@tomcloyd.com >> (email) > << TomCloyd.com >> (website & psychotherapy weblog) << > sleightmind.wordpress.com >> (mental health issues weblog) > << directpathdesign.com >> (web site design & consultation) > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > ---- Bob Hutchison -- tumblelog at http://www.recursive.ca/so/ Recursive Design Inc. -- weblog at http://www.recursive.ca/hutch http://www.recursive.ca/ -- works on http://www.raconteur.info/cms-for-static-content/home/