Class: Olelo::VirtualFS::Native

Inherits:
Olelo::VirtualFS show all
Defined in:
lib/olelo/virtualfs.rb

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ Native

Returns a new instance of Native.



24
25
26
# File 'lib/olelo/virtualfs.rb', line 24

def initialize(dir)
  @dir = dir
end

Instance Method Details

#glob(*names) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/olelo/virtualfs.rb', line 34

def glob(*names)
  names.map do |name|
    Dir[real_path(name)].select {|f| File.file?(f) }
  end.flatten.each do |f|
    yield(self, f[@dir.length+1..-1])
  end
end

#mtime(name) ⇒ Object



48
49
50
# File 'lib/olelo/virtualfs.rb', line 48

def mtime(name)
  File.mtime(real_path(name))
end

#read(name) ⇒ Object



29
30
31
# File 'lib/olelo/virtualfs.rb', line 29

def read(name)
  File.read(real_path(name))
end

#real_path(name) ⇒ Object



43
44
45
# File 'lib/olelo/virtualfs.rb', line 43

def real_path(name)
  File.join(@dir, name)
end

#size(name) ⇒ Object



53
54
55
# File 'lib/olelo/virtualfs.rb', line 53

def size(name)
  File.stat(real_path(name)).size
end