Class: XML::DOM::Comment
- Inherits:
-
CharacterData
- Object
- Node
- CharacterData
- XML::DOM::Comment
- Defined in:
- lib/xml/dom/core.rb,
lib/xml/dom2/xpath.rb,
lib/xml/dom2/comment.rb
Overview
Class XML::DOM::Comment
superclass
CharacterData
Constant Summary
Constants inherited from Node
Node::ATTRIBUTE_NODE, Node::CDATA_SECTION_NODE, Node::COMMENT_NODE, Node::DOCUMENT_FRAGMENT_NODE, Node::DOCUMENT_NODE, Node::DOCUMENT_TYPE_NODE, Node::ELEMENT_NODE, Node::ENTITY_NODE, Node::ENTITY_REFERENCE_NODE, Node::NODE_NODE, Node::NOTATION_NODE, Node::PROCESSING_INSTRUCTION_NODE, Node::TEXT_NODE
Instance Method Summary collapse
- #_getMyLocation(parent) ⇒ Object
- #_getMyLocationInXPath(parent) ⇒ Object
-
#dump(depth = 0) ⇒ Object
— Comment#dump(depth =0).
-
#initialize(text = nil) ⇒ Comment
constructor
new(text) text: String.
-
#nodeName ⇒ Object
[DOM].
-
#nodeType ⇒ Object
[DOM].
-
#to_s ⇒ Object
— Comment#to_s.
Methods inherited from CharacterData
#appendData, #cloneNode, #data, #data=, #deleteData, #insertData, #length, #nodeValue, #nodeValue=, #replaceData, #substringData
Methods inherited from Node
#+, #<=>, #==, #[], #[]=, #__collectAncestorNS, #__collectDescendatNS, #__sibling, #_ancestor, #_checkNode, #_child, #_descendant, #_following, #_fsibling, #_getChildIndex, #_getNodeByAbsoluteLocationTerm, #_insertNodes, #_matchAttribute?, #_matchNode?, #_matchNodeAttributes?, #_matchNodeType?, #_nodesByLocationTerms, #_nodesByRelativeLocationTerm, #_preceding, #_psibling, #_removeFromTree, #_removeNode, #_searchID, #accept, #accept_name, #appendChild, #attributes, #childNodes, #childNodes=, #children_accept, #children_accept_name, #cloneNode, #each, #firstChild, #getDigest, #getNodesByXPath, #getNodesByXPointer, #hasAttributes, #hasChildNodes, #insertBefore, #inspect, #isSupported, #lastChild, #localname, #makeXPath, #makeXPointer, #namespaceURI, #nextSibling, #nodeValue, #nodeValue=, #ownerDocument, #ownerDocument=, #parentNode, #parentNode=, #prefix, #prefix=, #previousSibling, #removeChild, #replaceChild, #trim
Constructor Details
#initialize(text = nil) ⇒ Comment
new(text)
text: String
2589 2590 2591 2592 |
# File 'lib/xml/dom/core.rb', line 2589 def initialize(text = nil) super(text) raise "parameter error" if !text end |
Instance Method Details
#_getMyLocation(parent) ⇒ Object
2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 |
# File 'lib/xml/dom/core.rb', line 2639 def _getMyLocation(parent) index = 1 parent.childNodes do |child| if child == self return "child(#{index},#comment)" end if child.nodeType == COMMENT_NODE index += 1 end end nil end |
#_getMyLocationInXPath(parent) ⇒ Object
364 365 366 367 368 369 |
# File 'lib/xml/dom2/xpath.rb', line 364 def _getMyLocationInXPath(parent) n = parent.childNodes.to_a.select { |i| i.nodeType == COMMENT_NODE }.index(self) "comment()[#{n + 1}]" end |
#dump(depth = 0) ⇒ Object
— Comment#dump(depth =0)
dumps the Comment.
2634 2635 2636 2637 |
# File 'lib/xml/dom/core.rb', line 2634 def dump(depth = 0) print ' ' * depth * 2 print "<!--#{@value.inspect}-->\n" end |
#nodeName ⇒ Object
- DOM
2614 2615 2616 |
# File 'lib/xml/dom/core.rb', line 2614 def nodeName "#comment" end |
#nodeType ⇒ Object
- DOM
2603 2604 2605 |
# File 'lib/xml/dom/core.rb', line 2603 def nodeType COMMENT_NODE end |
#to_s ⇒ Object
— Comment#to_s
returns the string representation of the Comment.
2623 2624 2625 2626 2627 |
# File 'lib/xml/dom/core.rb', line 2623 def to_s ret = "<!--#{@value}-->" ret << "\n" if parentNode.nodeType == DOCUMENT_NODE ret end |