This project implements different custom enumerator methods:
- my_each, my_each_with_index, my_selct, my_all?, my_any?, my_none?, my_count, my_map, my_inject. Each method is expected to behave exactly like the equivalent built-in method in the Enumerable module
- This method accepts a block and iterates through each element and do the block operation to each element
- This method varies from the 'my_each' method in that it takes the index of the list or array elements as a block argument in addition to the element value
- This method iterates through an array or list and selects those elements which satisfies the given block condition and output a new array
- This method iterates through all the elements of a list or an array and checks if all satisfy the given condition. If all satisfy the given condition it returns true else when it finds an element that doesn't satisfy, it returns false.
- This method iterates through all the elements of a list or an array and checks until it finds one element which satisfies the given condition. If it gets one element that satisfies it returns true, otherwise it returns false.
- This method iterates through all the elements of a list or an array and checks until it finds one element which satisfies the given condition. If it gets one element that satisfies it returns false, otherwise it returns true.
- This method iterates through all the elements of a list and counts when an element satisfies the given condition. If the element does not satisfy the given condition, it skips to the next element. It returns the final count value.
- This method iterates through all the elements of a list and does the block operation to every element, stores the value into a new array, and returns the new array.
- This method iterates through all the elements of a list, accepts the yield value and the element value as arguments, and returns the final yield value.
- Ruby
- VS code
- Ruby
To run this project locally, please ensure you have Ruby installed on your machine, then clone this repository by running.
git clone https://github.com/henatan99/enumerators-
After cloning run
cd enumerators-
Lastly, run either of the commands listed in the getting started section above.
Run the code demonstrations below
ruby enumerable.rb
To run the test please make sure RSpec is installed in your machine.
cd enumerators-
rspec
👤 Iris Enaelle Kineza
- GitHub: @KinezaEnaelle
- Twitter: @IKineza
- LinkedIn: Iris Enaelle Kineza
👤 Henok Mossissa
- GitHub: @henatan99
- Twitter: @henatan99
- LinkedIn: Henok Mossissa
Contributions, issues, and feature requests are welcome!
Give a ⭐️ if you like this project!
This project is MIT licensed.