{"id":20010421,"url":"https://github.com/magynhard/class_interface","last_synced_at":"2025-05-04T20:30:48.118Z","repository":{"id":62555750,"uuid":"173438926","full_name":"magynhard/class_interface","owner":"magynhard","description":"Ruby gem to provide an interface pattern for classes","archived":false,"fork":false,"pushed_at":"2023-05-08T18:49:41.000Z","size":21,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-01T18:06:04.923Z","etag":null,"topics":["class-interface","interface","interface-pattern","pattern","ruby","ruby-gem"],"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/magynhard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-02T11:20:48.000Z","updated_at":"2023-05-08T18:49:46.000Z","dependencies_parsed_at":"2022-11-03T05:45:34.479Z","dependency_job_id":null,"html_url":"https://github.com/magynhard/class_interface","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magynhard%2Fclass_interface","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magynhard%2Fclass_interface/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magynhard%2Fclass_interface/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magynhard%2Fclass_interface/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magynhard","download_url":"https://codeload.github.com/magynhard/class_interface/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252395184,"owners_count":21740980,"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":["class-interface","interface","interface-pattern","pattern","ruby","ruby-gem"],"created_at":"2024-11-13T07:19:44.585Z","updated_at":"2025-05-04T20:30:47.814Z","avatar_url":"https://github.com/magynhard.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# class_interface\n[![Gem](https://img.shields.io/gem/v/class_interface?color=default\u0026style=plastic\u0026logo=ruby\u0026logoColor=red)](https://rubygems.org/gems/class_interface)\n![downloads](https://img.shields.io/gem/dt/class_interface?color=blue\u0026style=plastic)\n[![License: MIT](https://img.shields.io/badge/License-MIT-gold.svg?style=plastic\u0026logo=mit)](LICENSE)\n\n\u003e Ruby gem to extend Ruby to support class interfaces you may know them from other programming languages like C++ or Java.\n\nRaises a variety of different exceptions when the requirements of the interface are not met.\n\nThat can be very handy in teams to declare requirements for specific types of classes.\n\n# Contents\n\n* [Installation](#installation)\n* [Usage](#usage)\n* [Documentation](#documentation)\n* [Contributing](#contributing)\n\n\n\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'class_interface'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install class_interface\n\n\n\n\n\u003ca name=\"usage\"\u003e\u003c/a\u003e\n## Usage\n\n### Defining an interface\n\nIt is a good idea, to start an interface name by convention with an I, following by a capitalized camel case constant name, i.e.: `IMyInterface, IHouse, IClassName, ...` \n\n```ruby\nclass IExample\n  MIN_AGE = Integer\n  DEFAULT_ENV = String\n  SOME_CONSTANT = nil\n\n  def self.some_static_method\n  end\n\n  def some_instance_method\n  end\nend\n```\n\n### Implementing an interface\n\n```ruby\nclass MyImplementation\n  MIN_AGE = 21\n  DEFAULT_ENV = 'dev' \n  SOME_CONSTANT = 'some_value'\n  \n  def specific_method\n    puts \"very specific\"\n  end\n  \n  def self.some_static_method\n    puts \"static method is implemented!\"\n  end\n  \n  def some_instance_method\n    # implementation\n  end\n  \n  def self.another_methods\n    # implementation\n  end\n  \n  implements IExample\nend\n```\n\n\n\n\n\n\u003ca name=\"documentation\"\u003e\u003c/a\u003e\n## Documentation\n```ruby\n#implements(InterfaceClassConstant)\n```\n\n_InterfaceClassConstant_ must be a valid InterfaceClassConstant or a String, containing a valid InterfaceClassConstant, i.e.: IMyInterface / \"IMyInterface\"\n\n### Methods\n\nAll defined methods in the interface class must be implemented in the implementing class.\nThe parameter count must be the same. A distinction is made between static and dynamic methods.\n\n### Constant Types\n\nAll CONSTANTS defined in the interface class must be implemented in the implementing class.\nCONSTANTS of interfaces may be defined with `nil`, to allow all types of definitions in the implementing class.\n\nOtherwise to specify a type, assign its class constant, e.g. `String`, `Array`, `MyCustomClass`, ...\nIf a specified type is defined, it is mandatory for the implementation to use that type.\n\n\n\n\n\n\u003ca name=\"contributing\"\u003e\u003c/a\u003e\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/magynhard/class_interface. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagynhard%2Fclass_interface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagynhard%2Fclass_interface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagynhard%2Fclass_interface/lists"}