mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
add File.path
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user