Module: OpenHAB::CoreExt::Between
- Included in:
- Date, DateTime, Java::Duration, Java::Instant, Java::LocalDate, Java::LocalTime, Java::Month, Java::MonthDay, Java::ZonedDateTime, Time
- Defined in:
- lib/openhab/core_ext/between.rb
Overview
Extensions that apply to both Date and Time classes
Instance Method Summary collapse
-
#between?(min, max = nil) ⇒ Object
Checks whether the the object falls between the given range.
Instance Method Details
#between?(min, max) ⇒ true, false #between?(range) ⇒ true, false
Checks whether the the object falls between the given range.
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 |