Class: Holidays::Definition::Parser::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/holidays/definition/parser/test.rb

Instance Method Summary collapse

Constructor Details

#initialize(validator) ⇒ Test

Returns a new instance of Test.



7
8
9
# File 'lib/holidays/definition/parser/test.rb', line 7

def initialize(validator)
  @validator = validator
end

Instance Method Details

#call(tests) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/holidays/definition/parser/test.rb', line 11

def call(tests)
  return [] if tests.nil?

  validate!(tests)

  tests.map do |t|
    given = t["given"]
    expect = t["expect"]

    Entity::Test.new(
      dates: parse_dates(given["date"]),
      regions: parse_regions(given["regions"]),
      options: parse_options(given["options"]),
      name: expect["name"],
      holiday?: is_holiday?(expect["holiday"]),
    )
  end
end