Class: Moxml::Adapter::CustomizedLeptris::DocumentPI

Inherits:
Object
  • Object
show all
Defined in:
lib/moxml/adapter/customized_leptris/document_pi.rb

Overview

Document-level processing instruction. libleptris stores these outside the element tree (a flat, document-ordered list with no prolog/epilog anchoring — its serializer emits them all before the root), reachable through Document#processing_instructions as [target, data] pairs. This pseudo-native gives the pairs a node identity so the moxml contract can list them as document children.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, data = "", parent_doc = nil) ⇒ DocumentPI

Returns a new instance of DocumentPI.



18
19
20
21
22
# File 'lib/moxml/adapter/customized_leptris/document_pi.rb', line 18

def initialize(target, data = "", parent_doc = nil)
  @target = target
  @data = data.to_s
  @parent_doc = parent_doc
end

Instance Attribute Details

#dataObject Also known as: content

Returns the value of attribute data.



14
15
16
# File 'lib/moxml/adapter/customized_leptris/document_pi.rb', line 14

def data
  @data
end

#parent_docObject

Returns the value of attribute parent_doc.



14
15
16
# File 'lib/moxml/adapter/customized_leptris/document_pi.rb', line 14

def parent_doc
  @parent_doc
end

#targetObject

Returns the value of attribute target.



14
15
16
# File 'lib/moxml/adapter/customized_leptris/document_pi.rb', line 14

def target
  @target
end

Instance Method Details

#==(other) ⇒ Object



28
29
30
# File 'lib/moxml/adapter/customized_leptris/document_pi.rb', line 28

def ==(other)
  other.is_a?(self.class) && target == other.target && data == other.data
end

#to_xmlObject



24
25
26
# File 'lib/moxml/adapter/customized_leptris/document_pi.rb', line 24

def to_xml
  data.empty? ? "<?#{target}?>" : "<?#{target} #{data}?>"
end