Class: Misc::DirUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/misc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ DirUtils

Returns a new instance of DirUtils.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/misc.rb', line 94

def initialize(path)
  @path = path
  @filenames = []

  if File.exists?(path) and File.directory?(path)
    Find.find(path) do |filename|
      if File.file?(filename)
        @filenames.push(filename)
      end
    end
  else
    raise "Parameter Error: #{path}"
  end
end

Instance Attribute Details

#filenamesObject (readonly)

Returns the value of attribute filenames.



93
94
95
# File 'lib/misc.rb', line 93

def filenames
  @filenames
end

#pathObject (readonly)

Returns the value of attribute path.



93
94
95
# File 'lib/misc.rb', line 93

def path
  @path
end

Instance Method Details

#filter_filename(filename_pattern) ⇒ Object



109
110
111
112
113
114
115
116
117
# File 'lib/misc.rb', line 109

def filter_filename(filename_pattern)
  result = []
  @filenames.each {|f|
    if f =~ filename_pattern
      result.push(f)
    end
  }
  result
end