The Enumerable module provides a set of methods that can be used with any collection-like object to work with its elements in an iterable and functional manner. The Enumerable provides collection classes with several traversal and searching methods, and with the ability to sort.
- 📖 About the Project
- 💻 Getting Started
- 👥 Authors
- 🔮 Future features
- 🤝 Contributing
- ⭐️ Show your support
- 🙏 Acknowledgements
- 📝 License
It is Done with the goal to practice modules and classes with ruby. The Enumerable module provides a set of methods that can be used with any collection-like object to work with its elements in an iterable and functional manner. This means that any object that includes the Enumerable module gains access to the methods defined within it. Done as a collaborative project.
- A class
MyListthat has an instance variable@list. with a method#eachthat yields successive members of@listand uses theMyEnumerablemodule. - A Module
MyEnumerablethat implements the following methods (they should have the same funcionality as methods in Enumerable):#all?#any?#filter
- Each class and module should has a separate .rb file.
To get a local copy up and running, follow these steps.
In order to run this project you need: Install ruby. To install ruby in your machine you can follow the steps listed in the Ruby installation instructions guide
Clone this repository to your desired folder:
cd my-enumerable
git clone git@github.com:myaccount/my-project.git
To run the project, execute the following command:
ruby my-enumerable.rb
# Create our list
irb> list = MyList.new(1, 2, 3, 4)
=> #<MyList: @list=[1, 2, 3, 4]>
# Test #all?
irb> list.all? {|e| e < 5}
=> true
irb> list.all? {|e| e > 5}
=> false
# Test #any?
irb> list.any? {|e| e == 2}
=> true
irb> list.any? {|e| e == 5}
=> false
# Test #filter
irb> list.filter {|e| e.even?}
=> [2, 4]👤 Obi Anthony
- GitHub: @megagig
- Twitter: @megagigsolution
- LinkedIn: Anthony Obi
👤 Ayokunnumi Omololu
- GitHub: @Ayokunnumi1
- Twitter: @Ayokunnumi
- LinkedIn: @Ayokunnumi
- Add more enumerable methods.
- Create more test scenarios.
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.
If you like this project give it a star 🌟🌟🌟
I would like to thank and Larissa Tao for using his template
This project is MIT licensed.