This commit is contained in:
Rikuoh Tsujitani 2024-06-06 21:06:31 +09:00
parent 4d5404ea3b
commit c325da4d19
Signed by: riq0h
GPG key ID: 010F09DEA298C717

4
ls.rb
View file

@ -36,7 +36,7 @@ end
def output(filenames) def output(filenames)
rows = (filenames.size / COLUMNS) rows = (filenames.size / COLUMNS)
length_limits = init_limit(filenames, rows) length_limits = limiter(filenames, rows)
(0...rows).each do |row| (0...rows).each do |row|
COLUMNS.times do |column| COLUMNS.times do |column|
index = row + column * rows index = row + column * rows
@ -46,7 +46,7 @@ def output(filenames)
end end
end end
def init_limit(filenames, rows) def limiter(filenames, rows)
filenames.each_slice(rows).map { _1.map(&:length).max } filenames.each_slice(rows).map { _1.map(&:length).max }
end end