{"id":19136852,"url":"https://github.com/mdub/another_enum","last_synced_at":"2025-05-06T20:12:13.312Z","repository":{"id":11901497,"uuid":"14465137","full_name":"mdub/another_enum","owner":"mdub","description":"Support for defining enumerated types in Ruby","archived":false,"fork":false,"pushed_at":"2020-04-21T01:01:37.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T10:16:46.226Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/mdub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-17T10:46:48.000Z","updated_at":"2020-04-21T01:01:40.000Z","dependencies_parsed_at":"2022-07-21T16:18:29.579Z","dependency_job_id":null,"html_url":"https://github.com/mdub/another_enum","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdub%2Fanother_enum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdub%2Fanother_enum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdub%2Fanother_enum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdub%2Fanother_enum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdub","download_url":"https://codeload.github.com/mdub/another_enum/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252761229,"owners_count":21800127,"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-11-09T06:35:42.403Z","updated_at":"2025-05-06T20:12:13.292Z","avatar_url":"https://github.com/mdub.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AnotherEnum\n\n`AnotherEnum` provides support for defining enumerated types in Ruby.  An enumerated type (or \"enum\") is a class with a finite (and usually small) set of predefined, named values.\n\n## Usage\n\nDefine a enumerated type by subclassing AnotherEnum.  Use `.define` to define allowed values:\n\n    require 'another_enum'\n\n    class Colour \u003c AnotherEnum\n      define :red\n      define :green\n      define :blue\n    end\n\nwhich become globally available:\n\n    Colour.red\n    Colour.green\n    Colour.blue\n\nEach value gets a code:\n\n    Colour.red.code     #=\u003e \"red\"\n\nwhich can be used later to lookup the value:\n\n    Colour[\"red\"]       #=\u003e Colour.red\n\nIt's easy to get all the defined values, or all the codes:\n\n    Colour.all          #=\u003e [Colour.red, Colour.green, Colour.blue]\n    Colour.codes        #=\u003e [\"red\", \"green\", \"blue\"]\n\n`AnotherEnum.define` takes a block, which can be used to define methods on the singleton values, e.g.\n\n    class CreditCardType \u003c AnotherEnum\n\n      define :visa do\n\n        def surcharge\n          0.08\n        end\n\n      end\n\n      define :amex do\n\n        def surcharge\n          0.16\n        end\n\n      end\n\n    end\n\nThere's even a shortcut for defining methods that return predefined values:\n\n    class CreditCardType \u003c AnotherEnum\n\n      define :visa do\n        hardcode name: \"Visa\"\n        hardcode surcharge: 0.08\n      end\n\n      define :amex do\n        hardcode name: \"American Express\"\n        hardcode surcharge: 0.16\n      end\n\n    end\n\n## Contributing\n\nIt's on GitHub. You know what to do.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdub%2Fanother_enum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdub%2Fanother_enum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdub%2Fanother_enum/lists"}