An open API service indexing awesome lists of open source software.

https://github.com/luigirazum/our-enumerable

In this project you will learn how to use a module inside your class.
https://github.com/luigirazum/our-enumerable

Last synced: 5 months ago
JSON representation

In this project you will learn how to use a module inside your class.

Awesome Lists containing this project

README

          

logo

### My Enumerable
In this project you will learn how to use a module inside a class. Also you will learn how to use `yield` to run a block received by a method where it is used, returning the value of the block.

# 📗 Table of Contents

- [📨 My Enumerable](#about-project)
- [🛠 Built With](#built-with)
- [Tech Stack](#tech-stack)
- [Key Features](#key-features)
- [💻 Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Setup](#setup)
- [Run](#run)
- [👥 Authors](#authors)
- [🔭 Future Features](#future-features)
- [🤝 Contributing](#contributing)
- [⭐️ Show your support](#support)
- [🙏 Acknowledgements](#acknowledgements)
- [📝 License](#license)


# 📨 My Enumerable

In this project you will learn how to use a module inside a class. Also you will learn how to use `yield` to run a block received by a method where it is used, returning the value of the block.

## 🛠 Built With

- ### Tech Stack

- ### Key Features

- #### 1️⃣ Create a class named `MyList`.
- It has a `@list` instance variable.
- It implements a method called `each` that yields successive members of `@list` and uses a module named `MyEnumerable`.

- #### 2️⃣ Create a module named `MyEnumerable`.
- It implements `all?`, `any?` and `filter` methods.
- These methods should have the same funcionality as methods in [Enumerable](https://ruby-doc.org/core-3.0.0/Enumerable.html) class.

- #### 2️⃣ Each class and module should has a separate `.rb` file.
- `MyEnumerable` module is used in the `MyList` class.
- Reuse code from different files.

(back to top)

## 💻 Getting Started

To get a local copy of this project up and running, follow these steps.

- ### Prerequisites

- In order to run this project locally you need `git` installed. Please got to [Getting Started - Installing Git guide](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and follow the steps described for your system to install `git`.
- Also you must have `Ruby` installed, you can go to the [Installing Ruby](https://www.ruby-lang.org/en/documentation/installation/) documentation and follow the steps for your computer OS.

- ### Setup
Clone this repository to your desired folder:
```sh
cd my-folder
git clone git@github.com:luigirazum/our-enumerable.git
cd our-enumerable
```
- ### Run
In the `our-enumerable` folder, use the following code to run the app
```rb
ruby my_list.rb
```

- ### Test
In the `irb` shell, use the following to test the code
```rb
# Import MyList class
irb> require_relative 'my_list'
=> true

# Create our list
irb> list = MyList.new(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]
```

(back to top)

## 👥 Author(s)

👨‍💻 **Luis Zubia**


👤 **Misal Azeem**

(back to top)

## 🔭 Future Features

- Add methods for more than one file.
- Use of `yield` in complex implementions.

(back to top)

## 🤝 Contributing

Contributions, issues, typos, and feature requests are welcome!

Feel free to check the [issues page](../../issues/).

(back to top)

## ⭐️ Show your support

If you like this project, your support giving a ⭐ will be highly appreciated.

(back to top)

## 🙏 Acknowledgments

- We would like to thank all those people that have helped us to be good programmers.

(back to top)

## 📝 License

This project is [MIT](./LICENSE) licensed.

(back to top)