From e6a2f0b98e217d1d55ce40ba477987cbff06626b Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 20 Dec 2022 19:51:18 +0900 Subject: [PATCH] mruby-dir/dir.rb: reformat according to coding standard --- mrbgems/mruby-dir/mrblib/dir.rb | 92 ++++++++++++++++----------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/mrbgems/mruby-dir/mrblib/dir.rb b/mrbgems/mruby-dir/mrblib/dir.rb index 065ca1c22..9baacc390 100644 --- a/mrbgems/mruby-dir/mrblib/dir.rb +++ b/mrbgems/mruby-dir/mrblib/dir.rb @@ -9,53 +9,53 @@ class Dir alias pos tell alias pos= seek - def self.entries(path) - a = [] - self.open(path) { |d| - while s = d.read - a << s - end - } - a - end - - def self.foreach(path, &block) - if block - self.open(path).each { |f| block.call(f) } - else - self.open(path).each - end - end - - def self.open(path, &block) - if block - d = self.new(path) - begin - block.call(d) - ensure - d.close - end - else - self.new(path) - end - end - - def self.chdir(path, &block) - my = self # workaround for https://github.com/mruby/mruby/issues/1579 - if block - wd = self.getwd - begin - self._chdir(path) - block.call(path) - ensure - my._chdir(wd) - end - else - self._chdir(path) - end - end - class << self + def entries(path) + a = [] + self.open(path) do |d| + while s = d.read + a << s + end + end + a + end + + def foreach(path, &block) + if block + self.open(path).each {|f| block.call(f) } + else + self.open(path).each + end + end + + def open(path, &block) + if block + d = self.new(path) + begin + block.call(d) + ensure + d.close + end + else + self.new(path) + end + end + + def chdir(path, &block) + my = self # workaround for https://github.com/mruby/mruby/issues/1579 + if block + wd = self.getwd + begin + self._chdir(path) + block.call(path) + ensure + my._chdir(wd) + end + else + self._chdir(path) + end + end + alias exists? exist? alias pwd getwd alias rmdir delete