This is a Ruby tree! It shows every object from the Ruby Programming Language in a tree format.
# Range.cover? (from ruby core) --- cover?(object) -> true or false cover?(range) -> true or false --- Returns `true` if the given argument is within `self`, `false` otherwise. With non-range argument `object`, evaluates with `<=` and `<`. For range `self` with included end value (`#exclude_end? == false`), evaluates thus: self.begin <= object <= self.end Examples: r = (1..4) r.cover?(1) # => true r.cover?(4) # => true r.cover?(0) # => false r.cover?(5) # => false r.cover?('foo') # => false r = ('a'..'d') r.cover?('a') # => true r.cover?('d') # => true r.cover?(' ') # => false r.cover?('e') # => false r.cover?(0) # => false For range `r` with excluded end value (`#exclude_end? == true`), evaluates thus: r.begin <= object < r.end Examples: r = (1...4) r.cover?(1) # => true r.cover?(3) # => true r.cover?(0) # => false r.cover?(4) # => false r.cover?('foo') # => false r = ('a'...'d') r.cover?('a') # => true r.cover?('c') # => true r.cover?(' ') # => false r.cover?('d') # => false r.cover?(0) # => false With range argument `range`, compares the first and last elements of `self` and `range`: r = (1..4) r.cover?(1..4) # => true r.cover?(0..4) # => false r.cover?(1..5) # => false r.cover?('a'..'d') # => false r = (1...4) r.cover?(1..3) # => true r.cover?(1..4) # => false If begin and end are numeric, #cover? behaves like #include? (1..3).cover?(1.5) # => true (1..3).include?(1.5) # => true But when not numeric, the two methods may differ: ('a'..'d').cover?('cc') # => true ('a'..'d').include?('cc') # => false Returns `false` if either: * The begin value of `self` is larger than its end value. * An internal call to `<=>` returns `nil`; that is, the operands are not comparable. Related: Range#include?.
This is MURDOC! A Ruby documentation browser inspired by Smalltalk-80. It allows you to learn about Ruby by browsing through its class hierarchies, and see any of its methods.