This Ruby utility script provides a range of useful functions for common tasks. It serves as a handy toolbox for Ruby developers, offering functions for string manipulation, file operations, and more.
-
ReverseString: Reverses the characters in a given string.
reversed_string = reverse_string('Hello, World!')
-
GenerateRandomString: Generates a random string of a specified length.
random_string = generate_random_string(10)
-
CountWords: Counts the number of words in a given string.
word_count = count_words('This is a sample sentence.')
-
ReadFileContent: Reads the content of a file and returns it as a string.
file_content = read_file_content('example.txt')
-
WriteToFile: Writes content to a file or creates a new file if it doesn't exist.
write_to_file('example.txt', 'This is some content.')
-
CalculateFactorial: Calculates the factorial of a given number.
factorial_result = calculate_factorial(5)
-
IsPalindrome: Checks if a given string is a palindrome.
is_palindrome = is_palindrome?('level')
-
SortArray: Sorts an array of numbers in ascending order.
sorted_array = sort_array([3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5])
-
EncryptString: Encrypts a string using a simple encryption algorithm.
encrypted_string = encrypt_string('secret')
-
DecryptString: Decrypts a previously encrypted string.
decrypted_string = decrypt_string(encrypted_string)
- Clone the repository to your local machine.
- Execute the script using a Ruby interpreter.
- Utilize the functions as needed in your Ruby projects.
This project is licensed under the MIT License - see the LICENSE file for details.