Daniel Finnie
2/20/2007 1:48:00 PM
That seems to be what facet/range/within does now.
daniel@daniel-desktop:~$ irb
>> require 'facet/range/within'
=> true
>> (1..3).within?(0..4)
=> true
>> (0..3).within?(0..4)
=> true
>> (-1..3).within?(0..4)
=> false
>> (1..4).within?(0..4)
=> true
>> (1..5).within?(0..4)
=> false
Whereas overlap?, IMHO, would return true to all of these. In the cool
ASCII diagrams, it would be like this:
|-----| a
|----| b
a.overlap? b #=> true
Dan
Daniel Schierbeck wrote:
> On Tue, 2007-02-20 at 10:56 +0900, danfinnie@optonline.net wrote:
>> I think that overlap? and within? are two different things, which I'm not sure you think from your email. Overlap? suggests, to me, that a subset of the things one range includes is the same as a subset of things that the other range includes. Within? suggests that all of one range is contained in a subset of the other range.
>
> Exactly, but that's not how it's implemented in Facets ;)
>
> I don't like #within? because it seems closer to #in? than to #include?.
> a.within? b suggests the following:
>
> a |-----|
> b |-------|
>
> I'd much rather have something else... #span?, perhaps?
>
>
> Cheers,
> Daniel
>
>
>