Class | Range |
In: |
lib/core/facets/range/combine.rb
lib/core/facets/range/overlap.rb lib/core/facets/range/to_r.rb lib/core/facets/range/within.rb lib/more/facets/random.rb |
Parent: | Object |
Combine intervals.
Range.combine(1..2, 2..4) #=> [1..4] Range.combine(1..2, 3..4) #=> [1..2, 3..4]
CREDIT: Trans
Combine ranges.
(1..2).combine(2..4) #=> [1..4] (1..2).combine(3..4) #=> [1..2, 3..4] TODO: Incorporate end-sentinal inclusion vs. exclusion.
CREDIT: Trans
Returns a two element array of the relationship between two Ranges.
Diagram:
Relationship Returns self |-----------| r |-----------| [0,0] self |-----------| r |---------| [-1,-1] self |---------| r |-----------| [1,1] self |-----------| r |----------| [-1,0] self |-----------| r |-----------| [-1,1] etc.
Example:
(0..3).umbrella(1..2) #=> [-1,-1]
CREDIT: Trans, Chris Kappler
Uses the Range#umbrella method to determine if another Range is anywhere within this Range.
(1..3).within?(0..4) #=> true
CREDIT: Trans