Sha256: a836072e0054bbc20de86549022aa6be99edb4e7d9888a762d72ed368c9c92c2
Contents?: true
Size: 721 Bytes
Versions: 1
Compression:
Stored size: 721 Bytes
Contents
require 'nano/range/umbrella' class Range # Uses the Range#umbrella method to determine # if another Range is _anywhere_ within this Range. # # (1..3).within?(0..4) #=> true # def within?(rng) case rng.umbrella(self) when [0,0], [-1,0], [0,-1], [-1,-1] return true else return false end end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCRange < Test::Unit::TestCase def test_within? assert( (4..5).within?(3..6) ) assert( (3..6).within?(3..6) ) assert(! (2..5).within?(3..6) ) assert(! (5..7).within?(3..6) ) end end =end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
facets-0.9.0 | lib/nano/range/within.rb |