[Nitro] Ruby question...

George Moschovitis george.moschovitis at gmail.com
Sun Mar 4 10:48:34 EST 2007


dirname is strange indeed... how about namespace ?

-g.

PS: I think I had a namespace method in an older version of Glue, this
must be somewhere in facets?


On 3/4/07, transfire at gmail.com <transfire at gmail.com> wrote:
>
>
> On Mar 4, 5:05 am, "George Moschovitis" <george.moschovi... at gmail.com>
> wrote:
> > Dear devs,
> >
> > lets say I have the variable:
> >
> > base = Namespace::MyModule
> >
> > I need a method (lets call it extract) that works like this:
> >
> > extract(base) # => Namespace
> >
> > any ideas?
>
> irb(main):005:0> require 'facets/core/module/dirname'
> => true
> irb(main):006:0> module X
> irb(main):007:1>   module Y
> irb(main):008:2>   end
> irb(main):009:1> end
> => nil
> irb(main):010:0> X::Y.basename
> NoMethodError: undefined method `basename' for X::Y:Module
>         from (irb):10
>         from :0
> irb(main):011:0> X::Y.dirname
> => "X"
>
> I know, the name 'dirname' is kind of odd, but I took the idea from
> File along with module/basename btw.
>
> Also
>
>   X::Y.name.split('::')
>
> I'd make that a method of Module too if I could think of a good name
> for it.
>
> T.
>
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general
>


-- 
http://blog.gmosx.com
http://cull.gr
http://www.joy.gr
http://nitroproject.org


More information about the Nitro-general mailing list