Class: Langulator::IndividualTranslations
- Inherits:
-
Object
- Object
- Langulator::IndividualTranslations
- Includes:
- Enumerable
- Defined in:
- lib/langulator/individual_translations.rb
Instance Attribute Summary collapse
-
#aggregate_location ⇒ Object
readonly
Returns the value of attribute aggregate_location.
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#source_language ⇒ Object
readonly
Returns the value of attribute source_language.
-
#target_languages ⇒ Object
readonly
Returns the value of attribute target_languages.
-
#translations ⇒ Object
readonly
Returns the value of attribute translations.
Instance Method Summary collapse
- #<<(*objects) ⇒ Object
- #aggregate ⇒ Object
- #compile ⇒ Object
- #each ⇒ Object
- #in(*languages) ⇒ Object
-
#initialize(options = {}) ⇒ IndividualTranslations
constructor
A new instance of IndividualTranslations.
- #source_translations ⇒ Object
- #target_translations ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ IndividualTranslations
Returns a new instance of IndividualTranslations.
6 7 8 9 10 11 |
# File 'lib/langulator/individual_translations.rb', line 6 def initialize( = {}) @aggregate_location = [:to] @base_path = [:base_path] @source_language = [:source_language] @target_languages = [:target_languages] end |
Instance Attribute Details
#aggregate_location ⇒ Object (readonly)
Returns the value of attribute aggregate_location.
5 6 7 |
# File 'lib/langulator/individual_translations.rb', line 5 def aggregate_location @aggregate_location end |
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
5 6 7 |
# File 'lib/langulator/individual_translations.rb', line 5 def base_path @base_path end |
#source_language ⇒ Object (readonly)
Returns the value of attribute source_language.
5 6 7 |
# File 'lib/langulator/individual_translations.rb', line 5 def source_language @source_language end |
#target_languages ⇒ Object (readonly)
Returns the value of attribute target_languages.
5 6 7 |
# File 'lib/langulator/individual_translations.rb', line 5 def target_languages @target_languages end |
#translations ⇒ Object (readonly)
Returns the value of attribute translations.
5 6 7 |
# File 'lib/langulator/individual_translations.rb', line 5 def translations @translations end |
Instance Method Details
#<<(*objects) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/langulator/individual_translations.rb', line 21 def <<(*objects) @translations ||= [] objects.flatten.each do |obj| translations << obj end end |
#aggregate ⇒ Object
48 49 50 |
# File 'lib/langulator/individual_translations.rb', line 48 def aggregate @aggregate ||= combine end |
#compile ⇒ Object
17 18 19 |
# File 'lib/langulator/individual_translations.rb', line 17 def compile aggregate.write end |
#each ⇒ Object
13 14 15 |
# File 'lib/langulator/individual_translations.rb', line 13 def each translations.each { |translation| yield translation } end |
#in(*languages) ⇒ Object
28 29 30 |
# File 'lib/langulator/individual_translations.rb', line 28 def in(*languages) select {|translation| languages.include?(translation.language)} end |
#source_translations ⇒ Object
32 33 34 35 36 |
# File 'lib/langulator/individual_translations.rb', line 32 def source_translations return [] unless source_language self.in(source_language) end |
#target_translations ⇒ Object
38 39 40 41 42 |
# File 'lib/langulator/individual_translations.rb', line 38 def target_translations return [] unless target_languages self.in(*target_languages) end |