Class: Range

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

Overview

Instance Method Summary collapse

Instance Method Details

#include_with_range?(value) ⇒ Boolean Also known as: include?

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


5
6
7
# File 'lib/timesheet/range_extensions.rb', line 5

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