method

cover?

Importance_1
Ruby on Rails latest stable (v6.1.7.7) - 0 notes - Class: CompareWithRange
cover?(value) public

Extends the default Range#cover? to support range comparisons.

(1..5).cover?(1..5)  # => true
(1..5).cover?(2..3)  # => true
(1..5).cover?(1...6) # => true
(1..5).cover?(2..6)  # => false

The native Range#cover? behavior is untouched.

('a'..'f').cover?('c') # => true
(5..9).cover?(11) # => false

The given range must be fully bounded, with both start and end.

Show source
Register or log in to add new notes.