Class: Vmit::VFS::Local
Class Method Summary collapse
-
.accept?(location) ⇒ Boolean
Whether this handler accepts the given location.
- .open(dir, *rest, &block) ⇒ Object
Instance Method Summary collapse
-
#initialize(base_path = nil) ⇒ Local
constructor
A new instance of Local.
- #open(name, *rest, &block) ⇒ Object
Methods inherited from Handler
Constructor Details
#initialize(base_path = nil) ⇒ Local
Returns a new instance of Local.
192 193 194 195 196 197 198 |
# File 'lib/vmit/vfs.rb', line 192 def initialize(base_path=nil) @base_path = base_path @base_path ||= '/' unless File.exist?(@base_path) raise Errno::ENOENT.new(@base_path) end end |
Class Method Details
.accept?(location) ⇒ Boolean
Whether this handler accepts the given location
188 189 190 |
# File 'lib/vmit/vfs.rb', line 188 def self.accept?(location) File.directory?(location.to_s) end |
.open(dir, *rest, &block) ⇒ Object
200 201 202 |
# File 'lib/vmit/vfs.rb', line 200 def self.open(dir, *rest, &block) self.new(dir).open(name, *rest, &block) end |
Instance Method Details
#open(name, *rest, &block) ⇒ Object
204 205 206 |
# File 'lib/vmit/vfs.rb', line 204 def open(name, *rest, &block) Kernel.open(File.join(@base_path, name), *rest, &block) end |