Class: IRODS4r::FileEnumerator

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/irods4r/directory.rb

Instance Method Summary collapse

Constructor Details

#initialize(dir_name) ⇒ FileEnumerator

Returns a new instance of FileEnumerator.



42
43
44
45
46
47
# File 'lib/irods4r/directory.rb', line 42

def initialize(dir_name)
  r = `ils #{dir_name}`
  @dir_name = dir_name
  @entries = r.lines.to_a
  @entries.shift # the first line is the directory name again
end

Instance Method Details

#eachObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/irods4r/directory.rb', line 30

def each()
  while e = @entries.shift
    e = e.strip
    if e.start_with? 'C-'
      # it's a directory
      yield Directory.new(e[3 .. -1])
    else
      yield File.new(::File.join(@dir_name, e))
    end
  end
end