Class: Range

Inherits:
Object
  • Object
show all
Defined in:
lib/timesheet/range_extensions.rb

Overview

Instance Method Summary collapse

Instance Method Details

#cover_with_range?(value) ⇒ Boolean Also known as: cover?



14
15
16
17
18
19
20
21
# File 'lib/timesheet/range_extensions.rb', line 14

def cover_with_range?(value)
  if value.is_a?(Range)
    last = value.exclude_end? ? value.last-1 : value.last
    self.cover?(value.first) && self.cover?(last)
  else
    cover_without_range?(value)
  end
end

#overlap?(range) ⇒ Boolean



8
9
10
# File 'lib/timesheet/range_extensions.rb', line 8

def overlap?(range)
  self.cover?(range.first) || range.cover?(self.first)
end