class Holidays::Definition::Validator::Region

Public Class Methods

new(regions_repo) click to toggle source
# File lib/holidays/definition/validator/region.rb, line 5
def initialize(regions_repo)
  @regions_repo = regions_repo
end

Public Instance Methods

valid?(r) click to toggle source
# File lib/holidays/definition/validator/region.rb, line 9
def valid?(r)
  return false unless r.is_a?(Symbol)

  region = find_wildcard_base(r)

  (region == :any ||
   @regions_repo.loaded?(region) ||
   @regions_repo.all_generated.include?(region))
end

Private Instance Methods

find_wildcard_base(region) click to toggle source

Ex: :gb_ transformed to :gb

# File lib/holidays/definition/validator/region.rb, line 22
def find_wildcard_base(region)
  r = region.to_s

  if r =~ /_$/
    base = r.split('_').first
  else
    base = r
  end

  base.to_sym
end