From 93b13c84c5a8c7b5e8ca1f7d8faac620fa916d42 Mon Sep 17 00:00:00 2001 From: Rikuoh Tsujitani Date: Wed, 22 May 2024 12:52:57 +0900 Subject: [PATCH] -l --- ls.rb | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/ls.rb b/ls.rb index 31432e7..d2e56a7 100644 --- a/ls.rb +++ b/ls.rb @@ -83,22 +83,15 @@ def permission(file_stat) end def file_type(file_stat) - case file_stat.ftype - when 'file' - print '-' - when 'directory' - print 'd' - when 'characterSpecial' - print 'c' - when 'blockSpecial' - print 'b' - when 'fifo' - print 'p' - when 'link' - print 'l' - when 'socket' - print 's' - end + { + 'fifo' => 'p', + 'characterSpecial' => 'c', + 'directory' => 'd', + 'blockSpecial' => 'b', + 'file' => '-', + 'link' => 'l', + 'socket' => 's' + }[file_stat] end def file_size(filenames)