Class: Translations::TranslationCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/translations/translation_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(translations, master) ⇒ TranslationCollection

Returns a new instance of TranslationCollection.



9
10
11
12
# File 'lib/translations/translation_collection.rb', line 9

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

Instance Attribute Details

#masterObject (readonly)

Returns the value of attribute master.



7
8
9
# File 'lib/translations/translation_collection.rb', line 7

def master
  @master
end

Instance Method Details

#eachObject



14
15
16
# File 'lib/translations/translation_collection.rb', line 14

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

#for_locale(locale) ⇒ Object



18
19
20
# File 'lib/translations/translation_collection.rb', line 18

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

#move(from, to) ⇒ Object



30
31
32
# File 'lib/translations/translation_collection.rb', line 30

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

#remove(key) ⇒ Object



26
27
28
# File 'lib/translations/translation_collection.rb', line 26

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

#slavesObject



22
23
24
# File 'lib/translations/translation_collection.rb', line 22

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