2007-08-18 23:21:29 +00:00
|
|
|
ObjectRange = Class.create({
|
2007-01-18 22:24:27 +00:00
|
|
|
initialize: function(start, end, exclusive) {
|
|
|
|
this.start = start;
|
|
|
|
this.end = end;
|
|
|
|
this.exclusive = exclusive;
|
|
|
|
},
|
|
|
|
|
|
|
|
_each: function(iterator) {
|
|
|
|
var value = this.start;
|
|
|
|
while (this.include(value)) {
|
|
|
|
iterator(value);
|
|
|
|
value = value.succ();
|
|
|
|
}
|
2007-08-18 23:21:29 +00:00
|
|
|
}
|
2007-01-18 22:24:27 +00:00
|
|
|
});
|
|
|
|
|
2007-08-18 23:21:29 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2007-01-18 22:24:27 +00:00
|
|
|
var $R = function(start, end, exclusive) {
|
|
|
|
return new ObjectRange(start, end, exclusive);
|
2007-08-18 23:21:29 +00:00
|
|
|
};
|