Class: Range
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Inherits: | Object |
Defined in: | activesupport/lib/active_support/core_ext/enumerable.rb, activesupport/lib/active_support/core_ext/object/json.rb, activesupport/lib/active_support/core_ext/range/overlaps.rb |
Constant Summary
::ActiveSupport::RangeWithFormat
- Prepended
Instance Method Summary
-
#overlaps?(other) ⇒ Boolean
Compare two ranges and see if they overlap each other (1..5).overlaps?(4..6) # => true (1..5).overlaps?(7..9) # => false.
::ActiveSupport::RangeWithFormat
- Prepended
#to_default_s | Alias for ActiveSupport::RangeWithFormat#to_s. |
#to_formatted_s | Alias for ActiveSupport::RangeWithFormat#to_s. |
#to_s | Convert range to a formatted string. |
::ActiveSupport::CompareWithRange
- Prepended
Instance Method Details
#overlaps?(other) ⇒ Boolean
Compare two ranges and see if they overlap each other
(1..5).overlaps?(4..6) # => true
(1..5).overlaps?(7..9) # => false
# File 'activesupport/lib/active_support/core_ext/range/overlaps.rb', line 7
def overlaps?(other) cover?(other.first) || other.cover?(first) end