Module: EpubForge::Utils::HtmlTranslatorQueue::ClassMethods

Defined in:
lib/epubforge/utils/html_translator_queue.rb

Instance Method Summary collapse

Instance Method Details

#categorize(translator) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/epubforge/utils/html_translator_queue.rb', line 34

def categorize( translator )
  unless GROUP_NAMES.include?( translator.group )
    puts "No group specified for html translator #{translator}.  Group must be one of the following symbols: #{GROUP_NAMES.map(&:inspect).inspect}"
    return false 
  end

  @translators[:all] << translator
  @translators[:named][translator.name] = translator if translator.name
  @translators[translator.group] << translator
end

#each_translator(&block) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/epubforge/utils/html_translator_queue.rb', line 49

def each_translator( &block )
  ordered_translators = []
  for group in GROUP_NAMES.map{|g| @translators[g].reverse }
    ordered_translators += group
  end

  if block_given?
    for translator in ordered_translators
      yield translator
    end
  else
    ordered_translators.to_enum
  end
end

#loader_pattern_register_item(translator) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/epubforge/utils/html_translator_queue.rb', line 14

def loader_pattern_register_item( translator )
  @translators ||= {}
  @translators[:all] ||= []
  @translators[:named] ||= {}

  for name in HtmlTranslatorQueue::GROUP_NAMES
    @translators[name] ||= []
  end

  self.categorize( translator )

  nil    # returning true will break loader
end

#location(name, path = nil) ⇒ Object



64
65
66
67
68
# File 'lib/epubforge/utils/html_translator_queue.rb', line 64

def location( name, path = nil )
  @exec_location ||= {}
  @exec_location[name] = path if path
  @exec_location[name]
end

#named(sym) ⇒ Object



45
46
47
# File 'lib/epubforge/utils/html_translator_queue.rb', line 45

def named( sym )
  @translators[:named][sym]
end

#translatorsObject



30
31
32
# File 'lib/epubforge/utils/html_translator_queue.rb', line 30

def translators
  @translators
end