diff --git a/lib/packages/ls.rb b/lib/packages/ls.rb index a6e39be..3f028fd 100755 --- a/lib/packages/ls.rb +++ b/lib/packages/ls.rb @@ -1,6 +1,10 @@ require 'set' require_relative 'core' +# The Ls class simulates a simplified version of the Unix 'ls' command, +# listing files and directories in the current working directory. +# It includes options for showing all files, including hidden ones, +# or just non-hidden files by default. class Ls def self.main params # Create new instance of Ruby data structure Set to add output to it @@ -24,7 +28,7 @@ def self.main params end # Use the Core class of ShellRB to print result - Core.print_result result + Core.print_result prepared_result result result end @@ -49,4 +53,13 @@ def self.show_non_hidden end non_hidden end + + def self.prepared_result unprepared_result + array = unprepared_result.to_a + + array.each_with_index do |entry, index| + array[index] = "#{entry} " unless index == array.size - 1 + end + Set.new(array) + end end