[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: FileTest.relative?
From:       Luis Lavena <luislavena () gmail ! com>
Date:       2010-12-21 23:52:29
Message-ID: b332128b-95bb-48ad-87c1-4e2d2c6c71fd () s4g2000yql ! googlegroups ! com
[Download RAW message or body]

On Dec 21, 8:35 pm, Intransition <transf...@gmail.com> wrote:
> It seems FileTest lacks a `relative?` method (and conversely `absolute?
> `). I need such a method. I went to write one but found my self not
> 100% certain about it being cross-platform. I wrote:
>
>   module FileTest
>     module_function
>
>     def relative?(path)
>       /\A[\/\\]/ !~ File.expand_path(path)
>     end
>   end
>
>
> Is all that really necessary? My version may be too simplistic, but
> surely there is more concise way to do this?

Your code is not contemplating drive letters.

--
Luis Lavena


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic