From: Evan Phoenix Date: 2010-03-25T03:44:02+09:00 Subject: [ruby-core:28947] Re: [Feature #1961] Kernel#__dir__ On Mar 24, 2010, at 2:28 AM, Charles Oliver Nutter wrote: > This is nice but would not be backward compatible with code that depends on __FILE__ actually being a string (any code that splits on / or builds a path with + "../" for example. Maybe a subclass of String? Is there a down side to that? > > class FileString < String > def dir > File.dirname(self) > end > end Sure, a String subclass seems pretty logical. - Evan > > - Charlie (mobile) > > On Mar 23, 2010, at 5:53 PM, Evan Phoenix wrote: > >> Perhaps __FILE__ should not be a raw String object, but rather a CurrentFile object. It could have a #to_str to return the normal String so it can be used like normal, but can provide methods like #dir, where __FILE__.dir == File.dirname(__FILE__). >> >> This solves the need for __DIR__ in a very clean, object oriented way. >> >> - Evan Phoenix > >