Class: Vmit::VFS::Local

Inherits:
Handler show all
Defined in:
lib/vmit/vfs.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Handler

from

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

Parameters:

  • uri (URI, String)

    location

Returns:

  • (Boolean)


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