Class: LLT::TeiHandler::PreProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/llt/tei_handler/pre_processor.rb

Instance Method Summary collapse

Constructor Details

#initialize(document) ⇒ PreProcessor

Returns a new instance of PreProcessor.



6
7
8
9
# File 'lib/llt/tei_handler/pre_processor.rb', line 6

def initialize(document)
  @document = Nokogiri::XML(document)
  try_to_find_tei_root unless is_tei?
end

Instance Method Details

#ignore_nodes(*nodes) ⇒ Object Also known as: remove_nodes



19
20
21
22
# File 'lib/llt/tei_handler/pre_processor.rb', line 19

def ignore_nodes(*nodes)
  @document.search(*nodes).each(&:remove)
  @document
end

#is_tei?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/llt/tei_handler/pre_processor.rb', line 15

def is_tei?
  @document.root.name =~ /^TEI/
end

#to_xmlObject



11
12
13
# File 'lib/llt/tei_handler/pre_processor.rb', line 11

def to_xml
  without_duplicate_declaration(@document.to_xml).strip
end