JS.Class2.1发布Ruby风格的JavaScriptJames Coglan不久前更新了JS.Class,发布了 JS.Class 2.1版本,使用JavaScript实现了Ruby的对象系统。var Event = new JS.Class({ include: JS.Observable, fire: function(data) { this.notifyObservers('fire', data); } });JS.Class is designed to make JavaScript behave like Ruby in terms of its OOP structures. To this end, it provides the following features: Classes and modules with Ruby-compatible inheritance Subclassing and mixins Late-binding arguments-optional super calls to parent classes and mixins Singleton methods and eigenclasses included, extended and inherited hooks Method binding Ports of various standard Ruby modules, including Enumerable, Hash, Set, Observable, Comparable, Forwardable Its inheritance system supports late-bound super() calls to parent classes and modules, including calls from singleton methods. It has been designed to mimick Ruby as closely as possible, so if you know Ruby you should feel right at home.
展开内容