enumerous v0.2.0
Enumerous
Handy functionality for your Arrays and Enumerables!
Installation
- 
Add the dependency to your shard.yml:dependencies: enumerous: github: acook/enumerous
- 
Run shards install
Usage
Erray Custom Array Type
An Erray is a strict superset of the core Array functionality without modifying any builtin classes. It works great with normal Arrays!
require "enumerous/erray"
has_different_elements = Erray{1,2}.similar [2,3]       #=> false
contains_same_elements = Erray{1,2}.similar [2,1]       #=> true
extra, missing = Erray{1,2}.diff [2,3]                  #=> {[3],[1]}
index_of_first_difference = Erray{1,2}.diff_index [1,3] #=> 1
{1,2}.find_and_map {|element| element > 1 && element.to_s }              #=> "2"
If you do not want Erray in the global namespace just pass -Dno_erray_alias to the compiler and you can still access it from Enumerous::Erray.
Optional Core Extension
require "enumerous/coreext"
has_different_elements = [1,2].similar [2,3]       #=> false
contains_same_elements = [1,2].similar [2,1]       #=> true
extra, missing = [1,2].diff [2,3]                  #=> {[3],[1]}
index_of_first_difference = [1,2].diff_index [1,3] #=> 1
[1,2].find_and_map {|element| element > 1 && element.to_s }              #=> "2"
{a: 1, b: 2}.find_and_map {|key, value| value > 1 && "#{key}:#{value}" } #=> "b:2"
Contributing
- Fork it (https://github.com/acook/enumerous/fork)
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- Anthony Cook - creator and maintainer
Repository
  enumerous
Owner
  
  Statistic
  - 0
- 0
- 0
- 0
- 0
- over 4 years ago
- February 14, 2021
License
  Other
Links
  
  Synced at
  Fri, 31 Oct 2025 03:34:39 GMT
Languages