Sha256: e2b6c3f30bb7cb9598b85fe90cd8d4f4aec68b89c8fef21f8c0557e3cf10c9eb

Contents?: true

Size: 801 Bytes

Versions: 7

Compression:

Stored size: 801 Bytes

Contents

require "translations/translation"

module Translations
  class TranslationCollection
    include Enumerable

    attr_reader :master

    def initialize translations, master
      @translations = translations
      @master = @translations.select { |translation| translation.locale == master }.first
    end

    def each
      @translations.each { |translation| yield translation }
    end

    def for_locale locale
      @translations.select { |translation| translation.locale == locale }.first
    end

    def slaves
      @translations.reject { |translation| translation == master }
    end

    def remove key
      @translations.each { |translation| translation.remove key }
    end

    def move from, to
      @translations.each { |translation| translation.move from, to }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
translations-0.3.3 lib/translations/translation_collection.rb
translations-0.3.2 lib/translations/translation_collection.rb
translations-0.3.1 lib/translations/translation_collection.rb
translations-0.3.0 lib/translations/translation_collection.rb
translations-0.2.1 lib/translations/translation_collection.rb
translations-0.2.0 lib/translations/translation_collection.rb
translations-0.1.0 lib/translations/translation_collection.rb