Class: LLT::TeiHandler::PreProcessor
- Inherits:
-
Object
- Object
- LLT::TeiHandler::PreProcessor
- Defined in:
- lib/llt/tei_handler/pre_processor.rb
Instance Method Summary collapse
- #ignore_nodes(*nodes) ⇒ Object (also: #remove_nodes)
-
#initialize(document) ⇒ PreProcessor
constructor
A new instance of PreProcessor.
- #is_tei? ⇒ Boolean
- #to_xml ⇒ Object
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
15 16 17 |
# File 'lib/llt/tei_handler/pre_processor.rb', line 15 def is_tei? @document.root.name =~ /^TEI/ end |
#to_xml ⇒ Object
11 12 13 |
# File 'lib/llt/tei_handler/pre_processor.rb', line 11 def to_xml without_duplicate_declaration(@document.to_xml).strip end |