module Rfc2425
class DirectoryInfo
class Field
end
end
end
I believe something like this is common:
include Rfc2425::DirectoryInfo
f = Field.new
f2 = Field.new
Chris
http://clabs.org
module Rfc2425
class DirectoryInfo
class Field
end
end
end
I believe something like this is common:
include Rfc2425::DirectoryInfo
f = Field.new
f2 = Field.new
Chris
http://clabs.org
Try Rob Partington’s ‘with.rb’
class Object
attr_reader :curObj
@curObj = []
def with(*args)
@curObj = [] if curObj == nil
if block_given?
@curObj.push(args[0])
yield
@curObj.pop
end
end
def method_missing(method, *args)
methname = method.id2name
if @curObj.size
if args.size > 0
@curObj[-1].send(methname, args)
else
@curObj[-1].send(methname)
end
end
end
end
-------------------->8 snip 8<---------------------------
Example of usage:
require “with”
class Fish
attr_reader :type, :name
def initialize(type, name="percy")
@type=type
@name=name
end
def moo(*args)
return "#{name} (a #{type}) says moo and #{args[0]}\n"
end
end
a=Fish.new(“halibut”)
b=Fish.new(“turbot”, “martin”)
c=Fish.new(“hake”)
with (a) { print moo("[default]"); print b.moo("[other object]") }
with (b) {
print moo(“pre-nest”)
with © { print moo(“nested”) }
print moo(“post-nest”)
}
-------------------------->8 snip 8<-------------------------------
Regards, Bret
Bret Jolly (Jou Lii Bair)
http://www.rexx.com/~oinkoink/