{"id":13747446,"url":"https://github.com/coreyhaines/enumeradical","last_synced_at":"2025-05-01T05:33:29.647Z","repository":{"id":2471651,"uuid":"3444267","full_name":"coreyhaines/enumeradical","owner":"coreyhaines","description":"Radical enumerable additions for enumerating and doing other awesome things","archived":false,"fork":false,"pushed_at":"2021-02-14T15:17:54.000Z","size":20,"stargazers_count":26,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-11T20:22:03.887Z","etag":null,"topics":[],"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/coreyhaines.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-02-14T21:45:30.000Z","updated_at":"2021-02-14T15:17:29.000Z","dependencies_parsed_at":"2022-08-30T20:20:52.827Z","dependency_job_id":null,"html_url":"https://github.com/coreyhaines/enumeradical","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreyhaines%2Fenumeradical","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreyhaines%2Fenumeradical/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreyhaines%2Fenumeradical/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreyhaines%2Fenumeradical/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coreyhaines","download_url":"https://codeload.github.com/coreyhaines/enumeradical/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242728424,"owners_count":20175935,"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":[],"created_at":"2024-08-03T06:01:29.286Z","updated_at":"2025-03-09T17:30:51.011Z","avatar_url":"https://github.com/coreyhaines.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/coreyhaines/enumeradical.svg?branch=master)](https://travis-ci.org/coreyhaines/enumeradical)\n[![Code Climate](https://codeclimate.com/github/coreyhaines/enumeradical/badges/gpa.svg)](https://codeclimate.com/github/coreyhaines/enumeradical)\n\n# Enumeradical\n## A most amazing collection of useful functions filling common tasks when iterating over collections\n\n## What is this?\nI love enumerable. I really do. I use the functions it provides with the utmost alacrity. Nothing makes me sadder than seeing a #each used to populate an array. Once you start using them a lot in production systems, you notice a bunch of common patterns.\n\n## How do I use it?\nIt is a gem, so just do\n\n    gem install enumeradical\n\nthen rock the house by requiring it. It sets itself up!\n\n    require 'enumeradical'\n\n## Why would I use it?\n\n### I have an array of objects, and I need to convert them to another type.\n\n    class MyNumberPresenter\n      def initialize(number)\n        @number = number\n      end\n    end\n\n    [1,2,3].map { |number| MyNumberPresenter.new(number) }\n    # =\u003e [#\u003cMyNumberPresenter:0x0000010086b9c8 @number=1\u003e, #\u003cMyNumberPresenter:0x0000010086b630 @number=2\u003e,\n          #\u003cMyNumberPresenter:0x0000010086b540 @number=3\u003e]\n\n**NO MORE!** Use Enumerable#map_to(type)\n\n    class MyNumberPresenter\n      def initialize(number)\n        @number = number\n      end\n    end\n\n    [1,2,3].map_to MyNumberPresenter\n    # =\u003e [#\u003cMyNumberPresenter:0x0000010086b9c8 @number=1\u003e, #\u003cMyNumberPresenter:0x0000010086b630 @number=2\u003e,\n          #\u003cMyNumberPresenter:0x0000010086b540 @number=3\u003e]\n\n### I have an array of objects, and I want to map them to the value they give from indexing into another object.\n\n    require 'date'\n    [1,2,3].map { |index| Date::ABBR_DAYNAMES[index] } # =\u003e [\"Mon\", \"Tue\", \"Wed\"]\n\n**NO MORE!** Use Enumerable#map_into\n\n    require 'date'\n    [1,2,3].map_into Date::ABBR_DAYNAMES # =\u003e [\"Mon\", \"Tue\", \"Wed\"]\n\n\n### I have an array of objects, and I'd like to convert them using a given object's method.\n\n    class Converter\n      def hellos(times)\n        \"hello\"*times\n      end\n    end\n\n    converter = Converter.new\n\n    [1,2,3].map { |times| converter.hellos(times) }\n    # =\u003e [\"hello\", \"hellohello\", \"hellohellohello\"]\n\n**NO MORE!** Use Object#map_over\n\n    class Converter\n      def hellos(times)\n        \"hello\"*times\n      end\n    end\n\n    converter = Converter.new\n\n    converter.map_over [1,2,3], :hellos\n    # =\u003e [\"hello\", \"hellohello\", \"hellohellohello\"]\n\n### I have an array of objects, and I'd like to sort them based on another enumerable.\n\n    class Thingy\n      def initialize(foo)\n        self.foo = foo\n      end\n      attr_accessor :foo\n    end\n\n    thingies = [Thingy.new(\"abc\"), Thingy.new(\"def\"), Thingy.new(\"ghi\")]\n    arry = [\"def\", \"abc\", \"ghi\"]\n\n    thingies.sort_like(arry, :foo)\n    # OR\n    thingies.sort_like(arry) { |t| t.foo }\n\n## Is this useful?\nYES!!!!! Use it.\n\n## Who built this\n[Corey Haines](http://github.com/coreyhaines) and [Ryan Briones](http://github.com/ryanbriones)\n\n## License\n\nMIT. See [LICENSE](https://github.com/coreyhaines/enumeradical/blob/master/License.txt)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoreyhaines%2Fenumeradical","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoreyhaines%2Fenumeradical","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoreyhaines%2Fenumeradical/lists"}