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 (and answer mutations: creation routes native via add_pi; removal has no engine entry).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of DocumentPI.



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

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.



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

def data
  @data
end

#parent_docObject

Returns the value of attribute parent_doc.



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

def parent_doc
  @parent_doc
end

#targetObject

Returns the value of attribute target.



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

def target
  @target
end

Instance Method Details

#==(other) ⇒ Object



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

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

#to_xmlObject



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

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