Posted on June 12, 2009 - by ruby
Js.Class Ruby style javascript
JS.Class is a library designed to facilitate object-oriented development in JavaScript. It implements Ruby’s core object, module and class system and some of its metaprogramming facilities, giving you a powerful base to build well-structured OOP.
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.
var Animal = new JS.Class({
initialize: function(name) {
this.name = name;
},
speak: function(things) {
return 'My name is ' + this.name + ' and I like ' + things;
}
});
Download & example available at it’s official website
This entry was posted on Friday, June 12th, 2009 at 22:49 and is filed under Miscellaneous. You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
