{"id":16382485,"url":"https://github.com/andyobtiva/array_include_methods","last_synced_at":"2025-07-01T16:07:14.897Z","repository":{"id":38184739,"uuid":"268530264","full_name":"AndyObtiva/array_include_methods","owner":"AndyObtiva","description":"Array#include_all?, Array#include_any?, Array#include_array?, Array#array_index, Array#array_diff_indices, Array#array_intersection_indices, Array#counts, and Array#duplicates operations missing from basic Ruby Array API","archived":false,"fork":false,"pushed_at":"2023-04-12T06:09:04.000Z","size":53,"stargazers_count":6,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-31T19:27:12.338Z","etag":null,"topics":["array","array-methods","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AndyObtiva.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-01T13:29:18.000Z","updated_at":"2023-02-21T15:50:43.000Z","dependencies_parsed_at":"2024-10-11T04:05:35.724Z","dependency_job_id":"3afbc5bd-c7b7-44cc-8dbd-fcc7d8751058","html_url":"https://github.com/AndyObtiva/array_include_methods","commit_stats":{"total_commits":32,"total_committers":3,"mean_commits":"10.666666666666666","dds":0.125,"last_synced_commit":"9f4b2baec7db6b18bd0e93b21907062e585d5c27"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/AndyObtiva/array_include_methods","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndyObtiva%2Farray_include_methods","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndyObtiva%2Farray_include_methods/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndyObtiva%2Farray_include_methods/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndyObtiva%2Farray_include_methods/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AndyObtiva","download_url":"https://codeload.github.com/AndyObtiva/array_include_methods/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndyObtiva%2Farray_include_methods/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262996402,"owners_count":23396903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array","array-methods","ruby"],"created_at":"2024-10-11T04:05:33.818Z","updated_at":"2025-07-01T16:07:14.876Z","avatar_url":"https://github.com/AndyObtiva.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ArrayIncludeMethods 1.5.1 - [Ruby Refinement](https://docs.ruby-lang.org/en/master/syntax/refinements_rdoc.html)\n[![Gem Version](https://badge.fury.io/rb/array_include_methods.svg)](http://badge.fury.io/rb/array_include_methods)\n[![Build Status](https://travis-ci.com/AndyObtiva/array_include_methods.svg?branch=master)](https://travis-ci.com/AndyObtiva/array_include_methods)\n[![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/array_include_methods/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/array_include_methods?branch=master)\n\n`Array#include_all?`, `Array#include_any?`, `Array#include_array?`, `Array#array_index`, `Array#counts`, and `Array#duplicates` methods missing from basic Ruby `Array` API.\n\n## Setup\n\n### With Bundler:\n\nInclude the following in Gemfile:\n\n```ruby\ngem 'array_include_methods', '~\u003e 1.5.1'\n```\n\nRun:\n\n```\nbundle\n```\n\n### Without Bundler:\n\nRun:\n\n```\ngem install array_include_methods -v1.5.1\n```\n\n## Usage\n\nAdd the following line to your application if you are not requiring all gems via Bundler (e.g. `Bundler.require(:default)`):\n\n```ruby\nrequire 'array_include_methods'\n```\n\nTo activate the `ArrayIncludeMethods` [Ruby Refinement](https://docs.ruby-lang.org/en/master/syntax/refinements_rdoc.html) for the `Array` class, add the following line to every Ruby file that needs it:\n\n```ruby\nusing ArrayIncludeMethods\n```\n\nNow, you have `#include_all?`, `#include_any?`, `#include_array?`, `#array_index`, `#array_diff_indices`, and `#array_intersection_indices` methods on `Array` objects.\n\n## Examples\n\n### `Array#include_any?(*other_array)`\n\n```ruby\n[1, 2, 3, 4].include_any?(2, 4, 5) # returns true\n[1, 2, 3, 4].include_any?(6, 7) # returns false\n[1, 2, 3, 4].include_any?() # returns true\n[1, 2, 3, 4].include_any?(nil) # returns false\n```\n\n### `Array#include_all?(*other_array)`\n\n```ruby\n[1, 2, 3, 4].include_all?(2, 3) # returns true\n[1, 2, 3, 4].include_all?(2, 4) # returns true\n[1, 2, 3, 4].include_all?(4, 2) # returns true\n[1, 2, 3, 4].include_all?(4, 2, same_sort: true) # returns false\n[1, 2, 3, 4].include_all?(2, 4, 4) # returns true\n[1, 2, 3, 4].include_all?(2, 4, 5) # returns false\n[1, 2, 3, 4].include_all?() # returns true\n[1, 2, 3, 4].include_all?(nil) # returns false\n```\n\n### `Array#include_array?(other_array)`\n\n```ruby\n[1, 2, 3, 4].include_array?([2, 3]) # returns true\n[1, 2, 3, 4].include_array?([2, 4]) # returns false\n[1, 2, 3, 4].include_array?([4, 2]) # returns false\n[1, 2, 3, 4].include_array?([2, 4, 4]) # returns false\n[1, 2, 3, 4].include_array?([2, 4, 5]) # returns false\n[1, 2, 3, 4].include_array?([]) # returns true\n[1, 2, 3, 4].include_array?([nil]) # returns false\n```\n\n### `Array#array_index(other_array)`\n\nReturns first array index of `other_array` in `first_array` assuming `first_array.include_all?(other_array)` returns true\n\n```ruby\n[1, 2, 3, 4].array_index([2, 3, 4]) # returns 1\n[1, 2, 3, 4].array_index([2, 3]) # returns 1\n[1, 2, 3, 4].array_index([3, 4]) # returns 2\n[1, 2, 3, 4].array_index([2, 4]) # returns -1\n[1, 2, 3, 4].array_index([4, 2]) # returns -1\n[1, 2, 3, 4].array_index([2, 4, 5]) # returns -1\n[1, 2, 3, 4].array_index([]) # returns -1\n[1, 2, 3, 4].array_index(nil) # returns -1\n```\n\n### `Array#array_intersection_indexes(other_array)`\n(alias: `Array#array_intersection_indices(other_array)`)\n\nReturns indexes from `self` array for which elements match elements in `other_array` assuming same sort\n\n```ruby\n[1, 2, 3, 4].array_intersection_indexes([2, 3, 4]) # returns [1, 2, 3]\n[1, 2, 3, 4].array_intersection_indexes([2, 3]) # returns [1, 2]\n[1, 2, 3, 4].array_intersection_indexes([3, 4]) # returns [2, 3]\n[1, 2, 3, 4].array_intersection_indexes([2, 4]) # returns [1, 3]\n[1, 2, 3, 4].array_intersection_indexes([4, 2]) # returns [3]\n[1, 2, 3, 4].array_intersection_indexes([2, 4, 5]) # returns [1, 3]\n[1, 2, 3, 4].array_intersection_indexes([]) # returns []\n[1, 2, 3, 4].array_intersection_indexes(nil) # returns []\n```\n\n### `Array#array_diff_indexes(other_array)`\n(alias: `Array#array_diff_indices(other_array)`)\n\nReturns indexes from `self` array for which elements do not match elements in `other_array` assuming same sort\n\n```ruby\n[1, 2, 3, 4].array_diff_indexes([2, 3, 4]) # returns [0]\n[1, 2, 3, 4].array_diff_indexes([2, 3]) # returns [0, 3]\n[1, 2, 3, 4].array_diff_indexes([3, 4]) # returns [0, 1]\n[1, 2, 3, 4].array_diff_indexes([2, 4]) # returns [0, 2]\n[1, 2, 3, 4].array_diff_indexes([4, 2]) # returns [0, 1, 2]\n[1, 2, 3, 4].array_diff_indexes([2, 4, 5]) # returns [0, 2]\n[1, 2, 3, 4].array_diff_indexes([]) # returns [0, 1, 2, 3]\n[1, 2, 3, 4].array_diff_indexes(nil) # returns [0, 1, 2, 3]\n```\n\n### `Array#counts`\n\nReturns a hash of counts of every element in the array,\nperformed in linear time (running time of O(n)).\n\n```ruby\n[1, 2, 3, 4].counts # returns {1=\u003e1, 2=\u003e1, 3=\u003e1, 4=\u003e1}\n[1, :a, :a, :b, 'bee', 'see', true, true, nil, nil].counts # returns {1=\u003e1, :a=\u003e2, :b=\u003e1, \"bee\"=\u003e1, \"see\"=\u003e1, true=\u003e2, nil=\u003e2}\n[1, :a, :a, :b, 'bee', 'see', true, true, nil].counts # {1=\u003e1, :a=\u003e2, :b=\u003e1, \"bee\"=\u003e1, \"see\"=\u003e1, true=\u003e2, nil=\u003e1}\n[1, {a: 1}, :a, :a, :b, 'bee', 'see', true, true, {a: 1}, {a: 1}].counts # {1=\u003e1, {:a=\u003e1}=\u003e3, :a=\u003e2, :b=\u003e1, \"bee\"=\u003e1, \"see\"=\u003e1, true=\u003e2}\n[].counts # returns {}\n```\n\n### `Array#duplicates`\n\nReturns a single occurrence of all elements that repeated in an array,\nperformed in linear time (running time of O(n)).\n\n```ruby\n[1, 2, 3, 4].duplicates # returns []\n[1, :a, :a, :b, 'bee', 'see', true, true, nil, nil].duplicates # returns [:a, true, nil]\n[1, :a, :a, :b, 'bee', 'see', true, true, nil].duplicates # returns [:a, true]\n[1, {a: 1}, :a, :a, :b, 'bee', 'see', true, true, {a: 1}, {a: 1}].duplicates # returns [:a, true, {a: 1}]\n[].duplicates # returns []\n```\n\n## JRuby Compatibility\n\nThis gem is 100% compatible with JRuby.\n\n## Opal Compatibility\n\nThis gem degrades gracefully to monkey-patching in [Opal Ruby](https://opalrb.com) and provides a `using` method shim so consumer code does not have to change if it used gems that rely on the [Ruby refinement](https://docs.ruby-lang.org/en/master/syntax/refinements_rdoc.html).\n\n## RubyMotion Compatibility\n\nThis gem degrades gracefully to monkey-patching in [RubyMotion](http://www.rubymotion.com/) and provides a `using` method shim so consumer code does not have to change if it used gems that rely on the [Ruby refinement](https://docs.ruby-lang.org/en/master/syntax/refinements_rdoc.html).\n\n## TODO\n\n[TODO.md](TODO.md)\n\n## Change Log\n\n[CHANGELOG.md](CHANGELOG.md)\n\n## Contributing to array_include_methods\n \n* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.\n* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.\n* Fork the project.\n* Start a feature/bugfix branch.\n* Commit and push until you are happy with your contribution.\n* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.\n* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.\n\n## Copyright\n\n[MIT](LICENSE.txt)\n\nCopyright (c) 2020-2022 Andy Maleh. See [LICENSE.txt](LICENSE.txt) for further details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyobtiva%2Farray_include_methods","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandyobtiva%2Farray_include_methods","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandyobtiva%2Farray_include_methods/lists"}