Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lib/packages/ls.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand All @@ -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