summaryrefslogtreecommitdiffhomepage
path: root/mrblib
diff options
context:
space:
mode:
authortakahashim <[email protected]>2015-11-21 22:03:40 +0900
committertakahashim <[email protected]>2015-11-21 22:03:40 +0900
commit44473fecdd454574b8cab67da13c2d5bb809bee2 (patch)
tree3b0c9650eb51c5ea467ab440d20a7b681e4274f8 /mrblib
parent828551f86ce9a2dd0c1a8af39c8ac99ecc0859a0 (diff)
downloadmruby-44473fecdd454574b8cab67da13c2d5bb809bee2.tar.gz
mruby-44473fecdd454574b8cab67da13c2d5bb809bee2.zip
add File.path
Diffstat (limited to 'mrblib')
-rw-r--r--mrblib/file.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/mrblib/file.rb b/mrblib/file.rb
index aa0981930..f644ff691 100644
--- a/mrblib/file.rb
+++ b/mrblib/file.rb
@@ -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