在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):Yonaba/Lua-Class-System开源软件地址(OpenSource Url):https://github.com/Yonaba/Lua-Class-System开源编程语言(OpenSource Language):Lua 80.1%开源软件介绍(OpenSource Introduction):#LCS : Lua Class System# Lua Class System (LCS) is a small library which offers a clean, minimalistic but powerful API for (Pseudo) Object Oriented programming style using Lua. LCS is light-weight, abstract thus can fit in every project where OOP mechanisms are needed. ##Usage##
Add LCS.lua file inside your project. ##Full API Overview##
##Printing classes and objects
As of v1.2, a light feature have been added. local LCS = require 'LCS'
-- A Cat Class
local Cat = LCS.class({name = 'Animal'})
-- Init
function Cat:init(name)
self.name = name
end
print(Cat) --> "class: <table: 0058C4C0>"
local kitten = Cat('kitty')
print(kitten) --> "object: <table: 0058C628>" Yet, this behaviour can still be easily overriden if you want to provide your own output. Just attach a method named describe to the class. local LCS = require 'LCS'
-- A Cat Class
local Cat = LCS.class({name = 'Animal'})
-- Init
function Cat:init(name)
self.name = name
end
print(Cat) --> "class: <table: 0058C4C0>"
local kitten = Cat('kitty')
print(kitten) --> "object: <table: 0058C628>"
-- Now providing a describe method to have our own output
function Cat:describe()
return self.name
end
print(Cat) --> "Animal"
print(kitten) --> "kitty"" Note: describe method can be passed a variable number of arguments. ##Documentation##
##License##
This work is under zLIB License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论