lib/folio/fileobject.rb in folio-0.3.0 vs lib/folio/fileobject.rb in folio-0.4.0
- old
+ new
@@ -18,11 +18,11 @@
# Factory method.
def self.[](*path)
path = ::File.join(*path)
- raise FileNotFound, "#{path}" unless ::File.exist?(path)
+ raise FileNotFound.new(path) unless ::File.exist?(path)
case ::File.ftype(path)
when 'file'
Document.new(path)
when 'directory'
@@ -36,18 +36,21 @@
when 'socket'
raise TypeError # Socket.new(path) ?
when 'fifo'
raise TypeError # Pipe?
else # 'unknown'
- raise TypeError
+ raise FileNotFound.new(path)
end
end
private
def initialize(path)
- raise FileNotFound, "#{path}" unless ::File.exist?(path)
@path = ::File.expand_path(path)
+ assert_exists if ::File.exist?(@path)
+ end
+
+ def assert_exists
end
public
attr :path