Module: OpenHAB::CoreExt::Between

Overview

Extensions that apply to both Date and Time classes

Instance Method Summary collapse

Instance Method Details

#between?(min, max) ⇒ true, false #between?(range) ⇒ true, false

Checks whether the the object falls between the given range.

Overloads:

  • #between?(min, max) ⇒ true, false

    Parameters:

    • min (Object)

      The minimum value to check, inclusive

    • max (Object)

      The maximum value to check, inclusive

    Returns:

    • (true, false)
  • #between?(range) ⇒ true, false

    Parameters:

    • range (Range)

      A range to check

    Returns:

    • (true, false)


19
20
21
22
23
24
25
26
27
28
29
# File 'lib/openhab/core_ext/between.rb', line 19

def between?(min, max = nil)
  range = if max
            Range.new(min, max, false)
          else
            raise ArgumentError, "Expecting a range when given a single argument" unless min.is_a?(Range)

            min
          end

  OpenHAB::DSL.between(range).cover?(self)
end