{"id":18481777,"url":"https://github.com/joker1007/max_value","last_synced_at":"2025-07-23T07:03:26.321Z","repository":{"id":10942574,"uuid":"13250283","full_name":"joker1007/max_value","owner":"joker1007","description":"It makes easier to access first element's attribute after max_by or min_by","archived":false,"fork":false,"pushed_at":"2013-10-01T18:39:56.000Z","size":112,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-13T19:56:28.371Z","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/joker1007.png","metadata":{"files":{"readme":"README.md","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":"2013-10-01T17:14:16.000Z","updated_at":"2013-10-02T18:15:03.000Z","dependencies_parsed_at":"2022-09-10T17:11:51.342Z","dependency_job_id":null,"html_url":"https://github.com/joker1007/max_value","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/joker1007/max_value","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joker1007%2Fmax_value","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joker1007%2Fmax_value/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joker1007%2Fmax_value/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joker1007%2Fmax_value/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joker1007","download_url":"https://codeload.github.com/joker1007/max_value/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joker1007%2Fmax_value/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266633043,"owners_count":23959466,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-06T12:25:28.044Z","updated_at":"2025-07-23T07:03:26.250Z","avatar_url":"https://github.com/joker1007.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MaxValue\n\nIt is Enumerable extension.\n\nIt makes easier to access first elements' attribute after max\\_by or min\\_by\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'max_value', github: 'joker1007/max_value'\n\nAnd then execute:\n\n    $ bundle\n\n## Usage\n\n```ruby\narray = [\n  Hashie::Mash.new({id: 1, name: \"name_c\"}),\n  Hashie::Mash.new({id: 2, name: \"name_a\"}),\n  Hashie::Mash.new({id: 3, name: \"name_z\"}),\n  Hashie::Mash.new({id: 4, name: \"name_b\"}),\n]\n\nhash_array = [\n  {id: 1, name: \"name_c\"},\n  {id: 2, name: \"name_a\"},\n  {id: 3, name: \"name_z\"},\n  {id: 4, name: \"name_b\"},\n]\n\n# before (so bad!!)\narray.max_by(\u0026:id).id               # =\u003e 4\nhash_array.max_by {|h| h[:id]}[:id] # =\u003e 4\n\n# after (so cool!!)\narray.max_value(:id)      # =\u003e 4\nhash_array.max_value(:id) # =\u003e 4\n\n# more example\narray.min_value(:id, \u0026:name)             # =\u003e 2 min_by(\u0026:name) and access to id\nhash_array.min_value(:id) {|h| h[:name]} # =\u003e 2\narray.sort_value(:id, \u0026:name)            # =\u003e [2, 4, 1, 3] sort_by(\u0026:name) and map by id\narray.lazy.sort_value(:id, \u0026:name)       # =\u003e Enumerator::Lazy sort_by(\u0026:name).lazy.map(\u0026:id)\n```\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoker1007%2Fmax_value","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoker1007%2Fmax_value","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoker1007%2Fmax_value/lists"}