{"id":13525942,"url":"https://github.com/rxi/classic","last_synced_at":"2025-04-04T10:07:04.505Z","repository":{"id":14507344,"uuid":"17220820","full_name":"rxi/classic","owner":"rxi","description":"Tiny class module for Lua","archived":false,"fork":false,"pushed_at":"2021-12-31T14:37:20.000Z","size":156,"stargazers_count":942,"open_issues_count":16,"forks_count":98,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-04-02T19:13:30.602Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Lua","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/rxi.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":"2014-02-26T18:38:01.000Z","updated_at":"2025-04-02T05:21:15.000Z","dependencies_parsed_at":"2022-07-16T16:47:05.835Z","dependency_job_id":null,"html_url":"https://github.com/rxi/classic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxi%2Fclassic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxi%2Fclassic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxi%2Fclassic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxi%2Fclassic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rxi","download_url":"https://codeload.github.com/rxi/classic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246939207,"owners_count":20857920,"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-01T06:01:23.708Z","updated_at":"2025-04-04T10:07:04.476Z","avatar_url":"https://github.com/rxi.png","language":"Lua","readme":"# Classic\n\nA tiny class module for Lua. Attempts to stay simple and provide decent\nperformance by avoiding unnecessary over-abstraction.\n\n\n## Usage\n\nThe [module](classic.lua) should be dropped in to an existing project and\nrequired by it:\n\n```lua\nObject = require \"classic\"\n```\n\nThe module returns the object base class which can be extended to create any\nadditional classes.\n\n\n### Creating a new class\n```lua\nPoint = Object:extend()\n\nfunction Point:new(x, y)\n  self.x = x or 0\n  self.y = y or 0\nend\n```\n\n### Creating a new object\n```lua\nlocal p = Point(10, 20)\n```\n\n### Extending an existing class\n```lua\nRect = Point:extend()\n\nfunction Rect:new(x, y, width, height)\n  Rect.super.new(self, x, y)\n  self.width = width or 0\n  self.height = height or 0\nend\n```\n\n### Checking an object's type\n```lua\nlocal p = Point(10, 20)\nprint(p:is(Object)) -- true\nprint(p:is(Point)) -- true\nprint(p:is(Rect)) -- false \n```\n\n### Using mixins\n```lua\nPairPrinter = Object:extend()\n\nfunction PairPrinter:printPairs()\n  for k, v in pairs(self) do\n    print(k, v)\n  end\nend\n\n\nPoint = Object:extend()\nPoint:implement(PairPrinter)\n\nfunction Point:new(x, y)\n  self.x = x or 0\n  self.y = y or 0\nend\n\n\nlocal p = Point()\np:printPairs()\n```\n\n### Using static variables\n```lua\nPoint = Object:extend()\nPoint.scale = 2\n\nfunction Point:new(x, y)\n  self.x = x or 0\n  self.y = y or 0\nend\n\nfunction Point:getScaled()\n  return self.x * Point.scale, self.y * Point.scale\nend\n```\n\n### Creating a metamethod\n```lua\nfunction Point:__tostring()\n  return self.x .. \", \" .. self.y\nend\n```\n\n\n## License\n\nThis module is free software; you can redistribute it and/or modify it under\nthe terms of the MIT license. See [LICENSE](LICENSE) for details.\n\n","funding_links":[],"categories":["OO","Game Development","Lua","Libraries"],"sub_categories":["Programming Frameworks \u0026 Languages","Programming Language"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxi%2Fclassic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frxi%2Fclassic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxi%2Fclassic/lists"}