(ON HOLD) Pop.Box is an easy to use GUI library for the LÖVE engine, intended for rapid prototyping.
Go to file
Paul Liverman III 8ea4b63878 Squashed 'src/lib/middleclass/' content from commit 27a64f1
git-subtree-dir: src/lib/middleclass
git-subtree-split: 27a64f107e61532006030a6168e4fe6a71eee9a2
2017-10-10 00:17:15 -07:00
performance Squashed 'src/lib/middleclass/' content from commit 27a64f1 2017-10-10 00:17:15 -07:00
rockspecs Squashed 'src/lib/middleclass/' content from commit 27a64f1 2017-10-10 00:17:15 -07:00
spec Squashed 'src/lib/middleclass/' content from commit 27a64f1 2017-10-10 00:17:15 -07:00
.travis.yml Squashed 'src/lib/middleclass/' content from commit 27a64f1 2017-10-10 00:17:15 -07:00
CHANGELOG.md Squashed 'src/lib/middleclass/' content from commit 27a64f1 2017-10-10 00:17:15 -07:00
middleclass.lua Squashed 'src/lib/middleclass/' content from commit 27a64f1 2017-10-10 00:17:15 -07:00
MIT-LICENSE.txt Squashed 'src/lib/middleclass/' content from commit 27a64f1 2017-10-10 00:17:15 -07:00
README.md Squashed 'src/lib/middleclass/' content from commit 27a64f1 2017-10-10 00:17:15 -07:00
UPDATING.md Squashed 'src/lib/middleclass/' content from commit 27a64f1 2017-10-10 00:17:15 -07:00

middleclass

Build Status Coverage Status

A simple OOP library for Lua. It has inheritance, metamethods (operators), class variables and weak mixin support.

Quick Look

local 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

Documentation

See the github wiki page for examples & documentation.

You can read the CHANGELOG.md file to see what has changed on each version of this library.

If you need help updating to a new middleclass version, read UPDATING.md.

Installation

Just 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'

Specs

This 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 tests

Middleclass also comes with a small performance test suite. Just run the following command:

lua performance/run.lua

License

Middleclass is distributed under the MIT license.