在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):kikito/middleclass开源软件地址(OpenSource Url):https://github.com/kikito/middleclass开源编程语言(OpenSource Language):Lua 100.0%开源软件介绍(OpenSource Introduction):middleclassA simple OOP library for Lua. It has inheritance, metamethods (operators), class variables and weak mixin support. Quick Looklocal class = require 'middleclass'
local Fruit = class('Fruit') -- 'Fruit' is the class' name
function Fruit:initialize(sweetness)
self.sweetness = sweetness
end
Fruit.static.sweetness_threshold = 5 -- class variable (also admits methods)
function Fruit:isSweet()
return self.sweetness > Fruit.sweetness_threshold
end
local Lemon = class('Lemon', Fruit) -- subclassing
function Lemon:initialize()
Fruit.initialize(self, 1) -- invoking the superclass' initializer
end
local lemon = Lemon:new()
print(lemon:isSweet()) -- false DocumentationSee the github wiki page for examples & documentation. You can read the If you need help updating to a new middleclass version, read InstallationJust copy the middleclass.lua file wherever you want it (for example on a lib/ folder). Then write this in any Lua file where you want to use it: local class = require 'middleclass' SpecsThis project uses busted for its specs. If you want to run the specs, you will have to install it first. Then just execute the following: cd /folder/where/the/spec/folder/is
busted Performance testsMiddleclass also comes with a small performance test suite. Just run the following command: lua performance/run.lua LicenseMiddleclass is distributed under the MIT license. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论