Sha256: e0b3071c1fca71379c6f09aa7941a8b1061389e9cedfa9bd7700e03c3e50746c

Contents?: true

Size: 892 Bytes

Versions: 5

Compression:

Stored size: 892 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
      @CARDS = CardCollection.new @CARDS
    end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
language_cards-0.1.2 lib/language_cards/language_cards.rb
language_cards-0.1.1 lib/language_cards/language_cards.rb
language_cards-0.1.0 lib/language_cards/language_cards.rb
language_cards-0.0.7 lib/language_cards/language_cards.rb
language_cards-0.0.6 lib/language_cards/language_cards.rb