{"id":13879745,"url":"https://github.com/marcoroth/easy_enum","last_synced_at":"2025-04-14T00:43:27.941Z","repository":{"id":41855808,"uuid":"184497528","full_name":"marcoroth/easy_enum","owner":"marcoroth","description":"Turn any Ruby class in an easy to use enum.","archived":false,"fork":false,"pushed_at":"2024-10-28T18:40:51.000Z","size":91,"stargazers_count":14,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T03:32:10.616Z","etag":null,"topics":["enum","enums","gem","ruby"],"latest_commit_sha":null,"homepage":"https://github.com/marcoroth/easy_enum","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/marcoroth.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-02T00:04:26.000Z","updated_at":"2024-11-07T18:49:37.000Z","dependencies_parsed_at":"2023-01-29T19:45:38.299Z","dependency_job_id":"8726755f-d956-4b05-9439-f1b9263ca9c6","html_url":"https://github.com/marcoroth/easy_enum","commit_stats":{"total_commits":59,"total_committers":4,"mean_commits":14.75,"dds":0.5254237288135593,"last_synced_commit":"8fb32bf3ac0458ced84df50f5700e9989affefdb"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoroth%2Feasy_enum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoroth%2Feasy_enum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoroth%2Feasy_enum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoroth%2Feasy_enum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcoroth","download_url":"https://codeload.github.com/marcoroth/easy_enum/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248804721,"owners_count":21164127,"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":["enum","enums","gem","ruby"],"created_at":"2024-08-06T08:02:31.214Z","updated_at":"2025-04-14T00:43:27.924Z","avatar_url":"https://github.com/marcoroth.png","language":"Ruby","readme":"# EasyEnum\n\nTurn any Ruby class in an easy to use enum.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'easy_enum'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install easy_enum\n\n## Basic Usage\n\n```ruby\nclass Color \u003c EasyEnum::EasyEnum\n  easy_enum(green: 0, red: 1, blue: 2)\nend\n\n# or\n\nclass Color \u003c EasyEnum::EasyEnum\n  self.easy_enum = {\n    green: 0,\n    red: 1,\n    blue: 2\n  }\nend\n\n```\n\n### Getting an Instance\n\n```ruby\nColor.green\nColor.red\nColor.blue\n\nColor.new(0)\nColor.new(1)\nColor.new(2)\n\nColor.key(:green)\nColor.key(:red)\nColor.key(:blue)\n\nColor.value(0)\nColor.value(1)\nColor.value(2)\n\n```\n\n### Getting Values\n\n```ruby\ngreen = Color.green\ngreen.value\n# =\u003e 0\n\nred = Color.red\nred.value\n# =\u003e 1\n\nblue = Color.blue\nblue.value\n# =\u003e 2\n\n```\n\n### Check the value of your instance\n\n```ruby\ncolor = Color.green\n\ncolor.green? # =\u003e true\ncolor.red? # =\u003e false\ncolor.blue? # =\u003e false\n\n```\n\n### Exploring the Enum\n\n```ruby\nColor.members\n# =\u003e {:green=\u003e0, :red=\u003e1, :blue=\u003e2}\n\nColor.keys\n# =\u003e [:green, :red, :blue]\n\nColor.values\n# =\u003e [0, 1, 2]\n\nColor.key?(:green)\n# =\u003e true\n\nColor.value?(0)\n# =\u003e true\n\n```\n\n\n### Comparison\n\n```ruby\ngreen = Color.green\n\ngreen == :green # =\u003e true\ngreen == 0 # =\u003e true\ngreen == Color.green # =\u003e true\ngreen == Color.key(:green) # =\u003e true\ngreen == Color.value(0) # =\u003e true\n\ngreen == Color.red # =\u003e false\n\n```\n\n\n### Redefining the value of your instance\n\n```ruby\ncolor = Color.green\ncolor.value # =\u003e 0\ncolor.key # =\u003e :green\n\ncolor.value = 1\ncolor.value # =\u003e 1\ncolor.key # =\u003e :red\n\ncolor.key = :blue\ncolor.value  # =\u003e 2\ncolor.key # =\u003e :blue\n\ncolor.key = :yellow\n# =\u003e raises EasyEnum::KeyNotInEnum\n\ncolor.value = 3\n# =\u003e raises EasyEnum::ValueNotInEnum\n\n```\n\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/marcoroth/easy_enum.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcoroth%2Feasy_enum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcoroth%2Feasy_enum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcoroth%2Feasy_enum/lists"}