Class: NumRu::LocalDir
- Inherits:
-
Object
- Object
- NumRu::LocalDir
- Defined in:
- lib/localdir.rb
Instance Method Summary collapse
- #each_dir ⇒ Object
-
#each_file(name_pattern = nil) ⇒ Object
name_pattern : regexp to limit by name.
- #each_gphys_file ⇒ Object
- #entries ⇒ Object
-
#initialize(path) ⇒ LocalDir
constructor
A new instance of LocalDir.
- #name ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(path) ⇒ LocalDir
Returns a new instance of LocalDir.
6 7 8 |
# File 'lib/localdir.rb', line 6 def initialize(path) @dir = Dir.new(path) end |
Instance Method Details
#each_dir ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/localdir.rb', line 39 def each_dir @dir.each do |name| path = File.join(self.path,name) if name!='.' && name!='..' && File.directory?(path) dir = self.class.new(path) mtime = File.mtime(path) yield(dir, mtime) end end nil end |
#each_file(name_pattern = nil) ⇒ Object
name_pattern : regexp to limit by name
67 68 69 70 71 72 73 74 75 |
# File 'lib/localdir.rb', line 67 def each_file(name_pattern = nil) @dir.each do |name| path = File.join(self.path,name) if File.file?(path) and (name_pattern.nil? or name_pattern =~ name) yield(path, File.mtime(path), File.size(path) ) end end end |
#each_gphys_file ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/localdir.rb', line 51 def each_gphys_file @dir.each do |name| path = File.join(self.path,name) if (File.file?(path) || (/nus$/=~path&&File.directory?(path))) && (klass=GPhys::IO.file2file_class(path)) # file = klass.open(path) mtime = File.mtime(path) size = File.size(path) # yield(file, mtime, size) yield(path, mtime, size, klass) end end nil end |
#entries ⇒ Object
35 36 37 |
# File 'lib/localdir.rb', line 35 def entries @dir.entries end |
#name ⇒ Object
31 32 33 |
# File 'lib/localdir.rb', line 31 def name File.basename(path) end |
#path ⇒ Object
27 28 29 |
# File 'lib/localdir.rb', line 27 def path @dir.path end |