Class: XcodeBuild::OutputTranslator

Inherits:
Object
  • Object
show all
Includes:
TranslationHelpers
Defined in:
lib/xcode_build/output_translator.rb

Defined Under Namespace

Modules: TranslationHelpers Classes: ConcreteTranslation, MissingDelegateMethodError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TranslationHelpers

#notify_delegate

Constructor Details

#initialize(delegate, options = {}) ⇒ OutputTranslator

Returns a new instance of OutputTranslator.



8
9
10
11
12
13
# File 'lib/xcode_build/output_translator.rb', line 8

def initialize(delegate, options = {})
  @delegate = delegate
  @translation_modules = []
  @translations = []
  OutputTranslator.prepare_instance(self) unless options[:ignore_global_translations]
end

Instance Attribute Details

#delegateObject (readonly)

Returns the value of attribute delegate.



6
7
8
# File 'lib/xcode_build/output_translator.rb', line 6

def delegate
  @delegate
end

#translationsObject (readonly)

Returns the value of attribute translations.



6
7
8
# File 'lib/xcode_build/output_translator.rb', line 6

def translations
  @translations
end

Class Method Details

.prepare_instance(translator) ⇒ Object



39
40
41
42
43
# File 'lib/xcode_build/output_translator.rb', line 39

def prepare_instance(translator)
  @any_instance_translations.each do |translation|
    translator.use_translation(translation)
  end
end

.use_translation(translation_module_or_key) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/xcode_build/output_translator.rb', line 28

def use_translation(translation_module_or_key)
  if translation_module_or_key.is_a?(Symbol)
    translation_module = Translations.registered_translation(translation_module_or_key)
  else
    translation_module = translation_module_or_key
  end
  
  @any_instance_translations ||= []
  @any_instance_translations << translation_module
end

Instance Method Details

#<<(line) ⇒ Object



15
16
17
18
# File 'lib/xcode_build/output_translator.rb', line 15

def <<(line)
  notify_delegate(:beginning_translation_of_line, :args => line)
  translations.each { |translation| translation.attempt_to_translate(line) }
end

#use_translation(translation_module) ⇒ Object



20
21
22
23
24
25
# File 'lib/xcode_build/output_translator.rb', line 20

def use_translation(translation_module)
  unless translation_module.nil? || @translation_modules.include?(translation_module)
    @translation_modules << translation_module
    @translations << ConcreteTranslation.new(@delegate, translation_module)
  end
end