/**
 * Copyright 2005-2007 Yu Zhang
 * Distributed under the GNU General Public License 2.0
 */

package com.xruby.runtime.value;

import java.io.File;

import com.xruby.runtime.lang.RubyBasic;
import com.xruby.runtime.lang.RubyRuntime;

public class RubyDir extends RubyBasic{
    private File dir_;
    
    public RubyDir(String path){
        super(RubyRuntime.DirClass);
        dir_ = new File(path);
    }
    
    public boolean isDirectory(){
        return dir_.isDirectory();
    }
    
}

@@ -152,16 +152,69 @@
 o.File;%0D
+%0Aimport java.util.ArrayList;%0D%0Aimport java.util.List;%0D
 %0A%0D%0Aimpor
@@ -369,209 +369,912 @@
     
-%0D%0A    public RubyDir(String path)%7B%0D%0A        super(RubyRuntime.DirClass);%0D%0A        dir_ = new File(path);%0D%0A    %7D%0D%0A    %0D%0A    public boolean isDirectory()%7B%0D%0A        return dir_.isDirectory();%0D%0A    %7D%0D%0A    
+private boolean isOpen = true;%0D%0A    private int curPos;%0D%0A    private List%3CString%3E list = new ArrayList%3CString%3E();%0D%0A    %0D%0A    public RubyDir(String path)%7B%0D%0A        super(RubyRuntime.DirClass);%0D%0A        dir_ = new File(path);%0D%0A        %0D%0A        list.add(%22.%22);%0D%0A        list.add(%22..%22);%0D%0A        String%5B%5D contents = dir_.list();%0D%0A        if(contents != null)%7B%0D%0A            for(int i=0;i%3Ccontents.length;i++)%7B%0D%0A                list.add(contents%5Bi%5D);%0D%0A            %7D%0D%0A        %7D%0D%0A        curPos = 0;%0D%0A    %7D%0D%0A    %0D%0A    public boolean isDirectory()%7B%0D%0A        return dir_.isDirectory();%0D%0A    %7D%0D%0A    %0D%0A    public void close()%7B%0D%0A        isOpen = false;%0D%0A    %7D%0D%0A    %0D%0A    public boolean isOpen()%7B%0D%0A        return isOpen;%0D%0A    %7D%0D%0A    %0D%0A    public String read()%7B%0D%0A        if(curPos %3E= list.size())%0D%0A            return null;%0D%0A        %0D%0A        String tmp = list.get(curPos);%0D%0A        curPos++;%0D%0A        return tmp;%0D%0A    %7D
 %0D%0A%7D%0D

add close and read method