Sha256: a76d6c1970f99a18f443fefe80fe1180284f47758b32065b9150e3b80d421209

Contents?: true

Size: 918 Bytes

Versions: 1

Compression:

Stored size: 918 Bytes

Contents

require_relative 'card_collection'
require_relative 'user_interface'

module LanguageCards
  class LanguageCards
    def initialize
      @CARDS = {}

      Dir[File.join(File.expand_path(File.join('..','..','..'), __FILE__), 'cards', '*.yml')].+(
        if ENV['HOME']
          Dir[File.join(File.expand_path(ENV['HOME']), '.language_cards', 'cards', '*.yml')]
        else
          []
        end
      ).
        each do |c|
        next unless yaml_data = YAML.load(File.open(c).read)
        for language in yaml_data.keys do
          if @CARDS.has_key? language
            @CARDS[language] = Hash(@CARDS[language]).merge(Hash(yaml_data[language]))
          else
            @CARDS.merge!({language => yaml_data[language]})
          end
        end

      end
      # Recursive Builder
      @CARDS = CardCollection.new @CARDS
    end

    def start
      UserInterface.new(@CARDS).start
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
language_cards-0.1.3 lib/language_cards/language_cards.rb