Module: INat::App::Config::ShiftAge

Defined in:
lib/inat/app/config/shiftage.rb

Class Method Summary collapse

Class Method Details

.parse(source) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/inat/app/config/shiftage.rb', line 7

def parse source
  source = source.to_i if /\d+/ === source
  source = source.to_s.downcase.intern if Symbol === source || String === source
  case source
  when nil
    0
  when Integer
    source
  when :daily, :weekly, :monthly
    source
  else
    raise TypeError, "Invalid shift age value: #{source}!"
  end
end