add File.path

This commit is contained in:
takahashim
2015-11-21 22:03:40 +09:00
parent 828551f86c
commit 44473fecdd
2 changed files with 19 additions and 0 deletions
+10
View File
@@ -170,4 +170,14 @@ class File < IO
ext = fname.split('.').last
ext.empty? ? '' : ".#{ext}"
end
def self.path(filename)
if filename.kind_of?(String)
filename
elsif filename.respond_to?(:to_path)
filename.to_path
else
raise TypeError, "no implicit conversion of #{filename.class} into String"
end
end
end