Class: Holidays::Definition::Validator::Region

Inherits:
Object
  • Object
show all
Defined in:
lib/holidays/definition/validator/region.rb

Instance Method Summary collapse

Constructor Details

#initialize(regions_repo) ⇒ Region

Returns a new instance of Region.



5
6
7
# File 'lib/holidays/definition/validator/region.rb', line 5

def initialize(regions_repo)
  @regions_repo = regions_repo
end

Instance Method Details

#valid?(r) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
# 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.exists?(region) ||
   region_in_static_definitions?(region))
end