Make ObjectRange use the new Class.create syntax.
This commit is contained in:
parent
5d37d39988
commit
e7bb042aa6
|
@ -1,5 +1,9 @@
|
|||
*SVN*
|
||||
|
||||
* Make ObjectRange use the new Class.create syntax. [Mislav Marohnić]
|
||||
|
||||
* Fix a failing ClassCreate test case in IE. [Tobie Langel]
|
||||
|
||||
* Complete rewrite of the Hash class.
|
||||
|
||||
!! BACKWARDS COMPATIBILITY CHANGE !! This new version of Hash is NOT backwards compatible with the former Hash class.
|
||||
|
|
22
src/range.js
22
src/range.js
|
@ -1,4 +1,4 @@
|
|||
ObjectRange = Class.create({
|
||||
var ObjectRange = Class.create(Enumerable, {
|
||||
initialize: function(start, end, exclusive) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
|
@ -11,19 +11,17 @@ ObjectRange = Class.create({
|
|||
iterator(value);
|
||||
value = value.succ();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
include: function(value) {
|
||||
if (value < this.start)
|
||||
return false;
|
||||
if (this.exclusive)
|
||||
return value < this.end;
|
||||
return value <= this.end;
|
||||
}
|
||||
});
|
||||
|
||||
Object.extend(ObjectRange.prototype, Enumerable);
|
||||
|
||||
ObjectRange.prototype.include = function(value) {
|
||||
if (value < this.start)
|
||||
return false;
|
||||
if (this.exclusive)
|
||||
return value < this.end;
|
||||
return value <= this.end;
|
||||
};
|
||||
|
||||
var $R = function(start, end, exclusive) {
|
||||
return new ObjectRange(start, end, exclusive);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue