0.1.4 • Published 11 years ago

class v0.1.4

Weekly downloads
144
License
-
Repository
github
Last release
11 years ago

class.js

A super simple ruby like class system with class property and instance property inheritance.

Class.js does not use constructors

var Animal = Class.new()
new Animal //=> TypeError: object is not a function

The reason Animal is not a Function is because functions cannot delegate their properties to another Function.

Examples

var Animal = Class.new({
  initialize: function(){
    this.birthdate = new Date;
  }
});

var Mammal = Animal.subclass(function(){

  this.initialize = function(name){
    this.name = name
    this.super('initialize').apply(this);
  };

});

var Dog    = Mammal.subclass();

var Cat    = Mammal.subclass();

var sparky = Dog.new('sparky');

var mitten = Cat.new('mitten');

Tests

npm install mocha
npm install expect.js
mocha -R list
0.1.4

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago