summaryrefslogtreecommitdiffhomepage
path: root/mrbgems
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-12-20 19:29:48 +0900
committerGitHub <[email protected]>2019-12-20 19:29:48 +0900
commit19fa77ddbb439a91e0227848a2fa3e33d5e6c4ea (patch)
treebc305b1bae658da217a7860be6812de48069e946 /mrbgems
parentadf358363c11a21b0e5aca21d041fb4da747da6d (diff)
parent5b30f789e5aa9a50ff0c95ffc98b553e8294ff0d (diff)
downloadmruby-19fa77ddbb439a91e0227848a2fa3e33d5e6c4ea.tar.gz
mruby-19fa77ddbb439a91e0227848a2fa3e33d5e6c4ea.zip
Merge pull request #4871 from dearblue/method-in-method
Avoid method in method
Diffstat (limited to 'mrbgems')
-rw-r--r--mrbgems/mruby-io/mrblib/file.rb66
1 files changed, 33 insertions, 33 deletions
diff --git a/mrbgems/mruby-io/mrblib/file.rb b/mrbgems/mruby-io/mrblib/file.rb
index 710333d6f..d3a4b1ec7 100644
--- a/mrbgems/mruby-io/mrblib/file.rb
+++ b/mrbgems/mruby-io/mrblib/file.rb
@@ -55,46 +55,46 @@ class File < IO
s
end
- def self.expand_path(path, default_dir = '.')
- def concat_path(path, base_path)
- if path[0] == "/" || path[1] == ':' # Windows root!
- expanded_path = path
- elsif path[0] == "~"
- if (path[1] == "/" || path[1] == nil)
- dir = path[1, path.size]
- home_dir = _gethome
-
- unless home_dir
- raise ArgumentError, "couldn't find HOME environment -- expanding '~'"
- end
-
- expanded_path = home_dir
- expanded_path += dir if dir
- expanded_path += "/"
- else
- splitted_path = path.split("/")
- user = splitted_path[0][1, splitted_path[0].size]
- dir = "/" + splitted_path[1, splitted_path.size].join("/")
+ def self._concat_path(path, base_path)
+ if path[0] == "/" || path[1] == ':' # Windows root!
+ expanded_path = path
+ elsif path[0] == "~"
+ if (path[1] == "/" || path[1] == nil)
+ dir = path[1, path.size]
+ home_dir = _gethome
+
+ unless home_dir
+ raise ArgumentError, "couldn't find HOME environment -- expanding '~'"
+ end
- home_dir = _gethome(user)
+ expanded_path = home_dir
+ expanded_path += dir if dir
+ expanded_path += "/"
+ else
+ splitted_path = path.split("/")
+ user = splitted_path[0][1, splitted_path[0].size]
+ dir = "/" + splitted_path[1, splitted_path.size].join("/")
- unless home_dir
- raise ArgumentError, "user #{user} doesn't exist"
- end
+ home_dir = _gethome(user)
- expanded_path = home_dir
- expanded_path += dir if dir
- expanded_path += "/"
+ unless home_dir
+ raise ArgumentError, "user #{user} doesn't exist"
end
- else
- expanded_path = concat_path(base_path, _getwd)
- expanded_path += "/" + path
- end
- expanded_path
+ expanded_path = home_dir
+ expanded_path += dir if dir
+ expanded_path += "/"
+ end
+ else
+ expanded_path = _concat_path(base_path, _getwd)
+ expanded_path += "/" + path
end
- expanded_path = concat_path(path, default_dir)
+ expanded_path
+ end
+
+ def self.expand_path(path, default_dir = '.')
+ expanded_path = _concat_path(path, default_dir)
drive_prefix = ""
if File::ALT_SEPARATOR && expanded_path.size > 2 &&
("A".."Z").include?(expanded_path[0].upcase) && expanded_path[1] == ":"