Class: Holiday::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/holiday/builder.rb

Overview

Sets up a container for holidays based on keys and alternative holiday names from yaml file.

Class Method Summary collapse

Class Method Details

.buildObject



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/holiday/builder.rb', line 5

def build
  return @container if defined?(@container)
  @container = {}
  Holiday.holidays.each do |holiday|
    Holiday.country_holidays[holiday]["as"].split(",").each do |other|
      @container[holiday] = holiday      # yaml key should be looked against as well
      @container[other.strip] = holiday  # natural name, labour day, is a key
    end
  end
  @container
end