Class: Montrose::Minute

Inherits:
Object
  • Object
show all
Defined in:
lib/montrose/minute.rb

Constant Summary collapse

MINUTES_IN_HOUR =
0.upto(59).to_a.freeze

Class Method Summary collapse

Class Method Details

.assert(minute) ⇒ Object

Raises:



15
16
17
18
19
# File 'lib/montrose/minute.rb', line 15

def assert(minute)
  raise ConfigurationError, "Out of range: #{MINUTES_IN_HOUR.inspect} does not include #{minute}" unless MINUTES_IN_HOUR.include?(minute)

  minute
end

.parse(arg) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/montrose/minute.rb', line 6

def parse(arg)
  case arg
  when String
    parse(arg.split(","))
  else
    Array(arg).map { |m| assert(m.to_i) }.presence
  end
end