Robert Klemme wrote: > 2010/2/12 John Ydil <john.gendrot / cnsi.fr>: >>> not exist in 1.8.2 (which is ancient btw - I cannot remember having >>> used it). >>> >>> Kind regards >>> >>> robert >> >> So there is no way i can do that in 1.8.2 ? > > You can write Enumerator yourself. It isn't too hard > > Enum = Struct.new :inst, :args do > include Enumerable > > def each(&b) > inst.send(*args, &b) > self > end > end > > class Object > def to_enum(*a) > Enum.new(self, a) > end > end > > :-) > > Kind regards > > robert Thanks again Robert but (there is always a BUT).... I copy paste the code you gave me Enum = Struct.new :inst, :args do include Enumerable def each(&b) inst.send(*args, &b) self end end class Object def to_enum(*a) Enum.new(self, a) end end File.to_enum(:foreach, "/etc/raddb/users").each_slice 4 do |name, ip, dump, table| puts name.strip! puts ip.strip! puts table.strip! end ./test.rb:31: undefined method `each_slice' for #<struct Enum inst=File, args=[:foreach, "/etc/raddb/users"]> (NoMethodError) I think we progress.... -- Posted via http://www.ruby-forum.com/.