https://github.com/msuliq/distributed_merge
Gem that adds a method to merge arrays of varying length with even distribution and interleaving.
https://github.com/msuliq/distributed_merge
ruby ruby-gem ruby-on-rails rubygem rubygems
Last synced: 4 months ago
JSON representation
Gem that adds a method to merge arrays of varying length with even distribution and interleaving.
- Host: GitHub
- URL: https://github.com/msuliq/distributed_merge
- Owner: msuliq
- License: mit
- Created: 2023-04-09T10:35:06.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-29T13:27:19.000Z (over 1 year ago)
- Last Synced: 2025-12-01T02:19:32.621Z (7 months ago)
- Topics: ruby, ruby-gem, ruby-on-rails, rubygem, rubygems
- Language: Ruby
- Homepage: https://rubygems.org/gems/distributed_merge
- Size: 43 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# DistributedMerge
`distributed_merge` is a Ruby gem that extends the `Array` class with a method for merging
and interleaving arrays of varying lengths, ensuring that elements are distributed as
evenly as possible. This method can be applied to any two-dimensional array containing two
or more sub-arrays of different sizes.
## Installation
Add the gem to your project by running:
```bash
bundle add distributed_merge
```
If you are not using Bundler to manage dependencies, install the gem directly with:
```bash
gem install distributed_merge
```
## Usage
To use the `distributed_merge` method, include the gem in your project:
```ruby
require 'distributed_merge'
```
Once included, you can call the `distributed_merge` method on any two-dimensional array
containing sub-arrays of varying lengths. The method will return a single merged array
with all elements interleaved and evenly distributed.
```ruby
[[1, 2, 3, 4], ['a', 'b'], ['C']].distributed_merge
# => [1, "b", 2, "C", 3, "a", 4]
```
In this example:
* The method merges the sub-arrays `[1, 2, 3, 4]`, `['a', 'b']`, and `['C']`.
* It ensures the elements are interleaved and distributed as evenly as possible in the final array.
## Contributing
Bug reports and pull requests are welcome at https://github.com/msuliq/distributed_merge. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/msuliq/distributed_merge/blob/main/CODE_OF_CONDUCT.md).
The best way to contribute would be to fork this repo, create a new branch from main, to merge the branch into main of the fork once the new code is in place and then open a pull request to merge forked main into the main of the present repo.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## Code of Conduct
Everyone interacting in the DistributedMerge project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/msuliq/distributed_merge/blob/main/CODE_OF_CONDUCT.md).