Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > File object. Undefined methods

Reply
Thread Tools

File object. Undefined methods

 
 
Olivier Moratin
Guest
Posts: n/a
 
      05-08-2009
Hi

I'm doing the following in the console of a Rails app

>> file = File.open("#{RAILS_ROOT}/xml/feed.xml")

=> #<File:/WebApps/app/xml/feed.xml>
>> f.dirname

NoMethodError: undefined method `dirname' for
#<File:/WebApps/app/xml/feed.xml>

I've tried other methods written in the doc of the File class to no
avail.

What am I missing?

Thanks
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Tim Hunter
Guest
Posts: n/a
 
      05-08-2009
Olivier Moratin wrote:
> Hi
>
> I'm doing the following in the console of a Rails app
>
>>> file = File.open("#{RAILS_ROOT}/xml/feed.xml")

> => #<File:/WebApps/app/xml/feed.xml>
>>> f.dirname

> NoMethodError: undefined method `dirname' for
> #<File:/WebApps/app/xml/feed.xml>
>
> I've tried other methods written in the doc of the File class to no
> avail.
>
> What am I missing?
>
> Thanks


Read the doc very carefully. dirname is a singleton method in File, not
an instance method.

File.dirname("#{RAILS_ROOT}/xml/feed.xml")
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to find the class methods of a class, just like'methods' finds the instance methods? Kenneth McDonald Ruby 5 09-26-2008 03:09 PM
Template methods, declaration and Implementation in header file andoverloaded methods. anto.anish@gmail.com C++ 0 06-09-2008 08:43 PM
typeof x == 'undefined' or x == undefined? -Lost Javascript 13 01-31-2007 12:04 AM
undefined vs. undefined (was: new Array() vs []) VK Javascript 45 09-12-2006 05:26 PM
undefined behavior or not undefined behavior? That is the question Mantorok Redgormor C Programming 70 02-17-2004 02:46 PM



Advertisments