From 44473fecdd454574b8cab67da13c2d5bb809bee2 Mon Sep 17 00:00:00 2001 From: takahashim Date: Sat, 21 Nov 2015 22:03:40 +0900 Subject: add File.path --- mrblib/file.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'mrblib') 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 -- cgit v1.2.3