# Class


Introduction:

You can use a simplified algorithm class. Exemple:

                  
User = Siga.Class({
  initialize: function(name, age) {
    this.name = name;
    this.age  = age;
  }
});

new User('Amine', '26');

                  
                

Inheritance

Pass an object to Siga.Class to inherit from it.

                  
SuperUser = Siga.Class(User, {
  initialize: function() {
    this.$super('initialize', arguments);
  },

  toString: function() {
    return "SuperUser: " + this.$super('toString');
  }
});     
                  
                

Mixins

Objects can be embedded within each other:

                  
MixinUser = Siga.Class({
  include: User,

  initialize: function(log) {
    this.log = log;
  }
});        
                  
                

You can also Fires an event. Example:

                  
SIga.events.fire(element, 'click');
         
                  
                

Add a 'DOM ready' callback. Example:

                  
Siga.events.ready(function() {
   // The DOM is ready
 });       
                  
                

Events can be chained with DOM calls. For example:

                  
Siga('p').bind('click', function(e) {
    alert('ouch');
  });        
                  
                

A generic event manager, based on Node's EventEmitter. For example:

                  
var EventEmitter = Siga.events.Emitter,
      emitter = new EventEmitter();

  emitter.on('testFired', function() {
    assert.ok(true);
  });

  emitter.emit('testFired')       
                  
                

Find a single item. For example:

                  
 var a = [1, 2, 3, 4, 5, 6, 7, 8];
 Siga.enumerable.detect(a, function(n) {
   return n === 3;
 });

 => 3      
                  
                

The DOM ready event handlers can also be set with:

                  
Siga.ready(function() { });

// Or just by passing a function to Siga()

Siga(function() {} );