Skip to content

Instantly share code, notes, and snippets.

@aishek
Created February 16, 2019 13:27
Show Gist options
  • Save aishek/a7e6d79a4f889a288779d46598f3c52a to your computer and use it in GitHub Desktop.
Save aishek/a7e6d79a4f889a288779d46598f3c52a to your computer and use it in GitHub Desktop.
middle = ->(array) { array[array.size / 2] }
def plural(string, plural_ending)
return string if string.end_with?(plural_ending)
"#{string}#{plural_ending}"
end
files = `ls -a`.split("\n")
files
.reject { |file| file.start_with?('.') }
.sort
.yield_self(&middle)
.yield_self { |file| plural(file, 's') }
.yield_self(&:upcase)
.tap { |file| puts file }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment