Class: Range
- Inherits:
-
Object
- Object
- Range
- Defined in:
- lib/timesheet/range_extensions.rb
Overview
Instance Method Summary collapse
- #include_with_range?(value) ⇒ Boolean (also: #include?)
- #overlap?(range) ⇒ Boolean
Instance Method Details
#include_with_range?(value) ⇒ Boolean Also known as: include?
11 12 13 14 15 16 17 18 |
# File 'lib/timesheet/range_extensions.rb', line 11 def include_with_range?(value) if value.is_a?(Range) last = value.exclude_end? ? value.last - 1 : value.last self.include?(value.first) && self.include?(last) else include_without_range?(value) end end |
#overlap?(range) ⇒ Boolean
5 6 7 |
# File 'lib/timesheet/range_extensions.rb', line 5 def overlap?(range) self.include?(range.first) || range.include?(self.first) end |