D
Daniel Berger
Hi all,
I'm trying to write a class where I want to delegate some instance
methods as FileTest class methods. For example:
require "forwardable"
class Foo < String
extend Forwardable
def_delegatorFileTest,:directory?)
def initialize(path)
@path = path
end
end
This doesn't work, however, since FileTest.directory? requires an
argument. What I would like is something like the following fictional
syntax:
def_delegatorFileTest,:directory?(@path))
I don't want to create an instance of File and delegate to that
instance because I don't know if @path will actually be valid or not
(among other reasons).
So, would something like this be possible?
Regards,
Dan
I'm trying to write a class where I want to delegate some instance
methods as FileTest class methods. For example:
require "forwardable"
class Foo < String
extend Forwardable
def_delegatorFileTest,:directory?)
def initialize(path)
@path = path
end
end
This doesn't work, however, since FileTest.directory? requires an
argument. What I would like is something like the following fictional
syntax:
def_delegatorFileTest,:directory?(@path))
I don't want to create an instance of File and delegate to that
instance because I don't know if @path will actually be valid or not
(among other reasons).
So, would something like this be possible?
Regards,
Dan