Class: RnDB::Slice
- Inherits:
-
Range
- Object
- Range
- RnDB::Slice
- Defined in:
- lib/rndb/slice.rb
Instance Method Summary collapse
-
#&(other) ⇒ Object
We need to intersect slices when processing query constraints.
-
#<=>(other) ⇒ Object
Because Slices in a Thicket are disjoint, we can sort by min or max.
-
#count ⇒ Object
Just in case the Range implementation is inefficient.
-
#initialize(min, max) ⇒ Slice
constructor
A range that knows how to sort and intersect itself, private to Thickets.
Constructor Details
#initialize(min, max) ⇒ Slice
A range that knows how to sort and intersect itself, private to Thickets.
6 7 8 |
# File 'lib/rndb/slice.rb', line 6 def initialize(min, max) super(min.to_i, max.to_i) end |
Instance Method Details
#&(other) ⇒ Object
We need to intersect slices when processing query constraints.
21 22 23 24 |
# File 'lib/rndb/slice.rb', line 21 def &(other) return nil if min > other.max || max < other.min self.class.new([min, other.min].max, [max, other.max].min) end |
#<=>(other) ⇒ Object
Because Slices in a Thicket are disjoint, we can sort by min or max.
16 17 18 |
# File 'lib/rndb/slice.rb', line 16 def <=>(other) min <=> other.min end |
#count ⇒ Object
Just in case the Range implementation is inefficient.
11 12 13 |
# File 'lib/rndb/slice.rb', line 11 def count max - min + 1 end |