Hash对象实现一种Hash结构,也就是一个Key:Value对的集合。
Hash中的每个Item是一个有两个元素的array,前一个是Key,后一个是Value,每个Item也有两个不需加以说明的属性,key和value。
| Method | Kind | Arguments | Description |
|---|---|---|---|
| keys() | instance | (none) | 返回所有Item的key的集合的一个array。 |
| values() | (none) | 返回所有Item的value的集合的一个array。 | |
| merge(otherHash) | instance | otherHash: Hash object | 合并给出的Hash,返回一个新Hash。 |
| toQueryString() | instance | (none) | 以QueryString那样的样式返回hash中所有的item,例如: ’key1=value1&key2=value2&key3=value3’ |
| inspect() | instance | (none) | 用一种合适的方法显示hash中的key:value对。 |
继承自 Enumerable
用上、下边界描述一个对象区域。
| Property | Type | Kind | Description |
|---|---|---|---|
| start | (any) |
range的下边界 | |
| end | (any) | instance | range的上边界 |
| exclusive | Boolean | instance | 决定边界自身是不是range的一部分。 |
| Method | Kind | Arguments | Description |
|---|---|---|---|
| [ctor](start, end, exclusive) | constructor | start: the lower bound, end: the upper bound, exclusive: include the bounds in the range? | 创建一个range对象,从start生成到end,这里要注意的是,start和end必段类型一致,而且该类型要有succ()方法。 |
| include(searchedValue) | searchedValue: value that we are looking for | 检查一个value是不是在range中。 |
在这个程序包中 Class 对象在声明其他的类时候被用到 。用这个对象声明类使得新类支持 initialize() 方法,他起构造方法的作用。
看下面的例子
//declaring the class
var MySampleClass = Class.create();
//defining the rest of the class implmentation
MySampleClass.prototype = {
initialize: function(message) {
this.message = message;
},
showMessage: function(ajaxResponse) {
alert(this.message);
}
};
//now, let’s instantiate and use one object
var myTalker = new MySampleClass(’hi there.’);
myTalker.showMessage(); //displays alert
| Method | Kind | Arguments | Description |
|---|---|---|---|
| create(*) | (any) | 定义新类的构造方法。 |
这个对象被用作其他提供AJAX功能的类的根对象。
| Property | Type | Kind | Description |
|---|---|---|---|
| activeRequestCount | Number | instance | 正在处理中的Ajax请求的个数。 |
| Method | Kind | Arguments | Description |
|---|---|---|---|
| getTransport() | (none) | 返回新的XMLHttpRequest 对象。 |
继承自 Enumerable
这个对象维持一个在Ajax相关事件发生时将被调用的对象的列表。比如,你要设置一个全局钩子来处理Ajax操作异常,那么你就可以使用这个对象。
| Property | Type | Kind | Description |
|---|---|---|---|
| responders | Array | 被注册到Ajax事件通知的对象列表。 |
| Method | Kind | Arguments | Description |
|---|---|---|---|
| register(responderToAdd) | instance | responderToAdd: object with methods that will be called. | 被传入参数的对象应包含名如Ajax事件的系列方法(如onCreate,onComplete,onException)。通讯事件引发所有被注册的对象的合适名称的函数被调用。 |
| unregister(responderToRemove) | instance | responderToRemove: object to be removed from the list. | 从列表中移除。 |
| dispatch(callback, request, transport, json) | instance | callback: name of the AJAX event being reported, request: the Ajax.Request object responsible for the event, transport: the XMLHttpRequest object that carried (or is carrying) the AJAX call, json: the X-JSON header of the response (if present) | 遍历被注册的对象列表,找出有由callback参数决定的那个函数的对象。然后向这些函数传递其它的三个参数,如果Ajax响应中包含一个含有JSON内容的X-JSON HTTP头,那么它会被热行并传入json参数。如果事件是onException,那么transport参数会被异常代替,json不会传递。 |
请稍等,评论加载中...