Class: Misc::DirUtils
- Inherits:
-
Object
- Object
- Misc::DirUtils
- Defined in:
- lib/misc.rb
Instance Attribute Summary collapse
-
#filenames ⇒ Object
readonly
Returns the value of attribute filenames.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #filter_filename(filename_pattern) ⇒ Object
-
#initialize(path) ⇒ DirUtils
constructor
A new instance of DirUtils.
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
#filenames ⇒ Object (readonly)
Returns the value of attribute filenames.
93 94 95 |
# File 'lib/misc.rb', line 93 def filenames @filenames end |
#path ⇒ Object (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 |