class Montrose::Month

Constants

NAMES
NUMBERS

Public Class Methods

names() click to toggle source
# File lib/montrose/month.rb, line 22
def names
  NAMES
end
number(name) click to toggle source
# File lib/montrose/month.rb, line 30
def number(name)
  case name
  when Symbol, String
    string = name.to_s
    NAMES.index(string.titleize) || number(to_index(string))
  when 1..12
    name
  end
end
number!(name) click to toggle source
# File lib/montrose/month.rb, line 40
def number!(name)
  numbers = NAMES.map.with_index { |_n, i| i.to_s }.slice(1, 12)
  number(name) || raise(ConfigurationError,
    "Did not recognize month #{name}, must be one of #{(NAMES + numbers).inspect}")
end
numbers() click to toggle source
# File lib/montrose/month.rb, line 26
def numbers
  NUMBERS
end
parse(value) click to toggle source
# File lib/montrose/month.rb, line 9
def parse(value)
  case value
  when String
    parse(value.split(",").compact)
  when Array
    value.map { |m|
      Montrose::Month.number!(m)
    }.presence
  else
    parse(Array(value))
  end
end