Class: LLT::XmlHandler::PreProcessor
- Inherits:
-
Object
- Object
- LLT::XmlHandler::PreProcessor
- Defined in:
- lib/llt/xml_handler/pre_processor.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Instance Method Summary collapse
-
#initialize(document, root: nil, ns: nil) ⇒ PreProcessor
constructor
A new instance of PreProcessor.
- #remove_nodes(*nodes) ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(document, root: nil, ns: nil) ⇒ PreProcessor
Returns a new instance of PreProcessor.
8 9 10 11 12 13 14 |
# File 'lib/llt/xml_handler/pre_processor.rb', line 8 def initialize(document, root: nil, ns: nil) @document = Nokogiri::XML(document) @namespace = ns go_to_root(root) if root @document.encoding = "UTF-8" end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
6 7 8 |
# File 'lib/llt/xml_handler/pre_processor.rb', line 6 def document @document end |
Instance Method Details
#remove_nodes(*nodes) ⇒ Object
20 21 22 23 24 |
# File 'lib/llt/xml_handler/pre_processor.rb', line 20 def remove_nodes(*nodes) nodes.each do |node| @document.xpath(*to_xpath(node, @namespace)).each(&:remove) end end |
#to_xml ⇒ Object
16 17 18 |
# File 'lib/llt/xml_handler/pre_processor.rb', line 16 def to_xml without_duplicate_declaration(@document.to_xml).strip end |