class XML::DOM::Text
Class XML::DOM::Text
¶ ↑
superclass¶ ↑
Class XML::DOM::Text
¶ ↑
superclass¶ ↑
Public Class Methods
new(text = nil)
click to toggle source
Class Methods¶ ↑
Calls superclass method
XML::DOM::CharacterData::new
# File lib/xml/dom/core.rb, line 2460 def initialize(text = nil) super(text) end
Public Instance Methods
_getMyLocation(parent)
click to toggle source
# File lib/xml/dom/core.rb, line 2522 def _getMyLocation(parent) index = 1 parent.childNodes do |child| if child == self return "child(#{index},#text)" end if child.nodeType == TEXT_NODE index += 1 end end nil end
_getMyLocationInXPath(parent)
click to toggle source
# File lib/xml/dom2/xpath.rb, line 340 def _getMyLocationInXPath(parent) n = parent.childNodes.to_a.select { |i| i.nodeType == TEXT_NODE or i.nodeType == CDATA_SECTION_NODE }.index(self) "text()[#{n + 1}]" end
dump(depth = 0)
click to toggle source
# File lib/xml/dom/core.rb, line 2517 def dump(depth = 0) print ' ' * depth * 2 print "#{@value.inspect}\n" end
getDigest(algorithm = Digest::MD5, force = false)
click to toggle source
# File lib/xml/dom/digest.rb, line 36 def getDigest(algorithm = Digest::MD5, force = false) (!force && @digest) || @digest = algorithm.digest([TEXT_NODE].pack("N") + DOM.tou16(nodeValue)) @digest end
nodeName()
click to toggle source
# File lib/xml/dom/core.rb, line 2484 def nodeName "#text" end
nodeType()
click to toggle source
splitText(offset)
click to toggle source
# File lib/xml/dom/core.rb, line 2542 def splitText(offset) if offset > @value.length || offset < 0 raise DOMException.new(DOMException::INDEX_SIZE_ERR) end newText = @value[offset, @value.length] newNode = Text.new(newText) if !self.parentNode.nil? self.parentNode.insertAfter(newNode, self) end @value[offset, @value.length] = "" newNode end
to_s()
click to toggle source
# File lib/xml/dom/core.rb, line 2493 def to_s ret = "" @value.each_byte do |code| case (code) when 13 ret << sprintf("&#x%X;", code) when ?& ret << "&" when ?< ret << "<" when ?> ret << ">" else ret << code end end ret end
trim(preserve = false)
click to toggle source
# File lib/xml/dom/core.rb, line 2560 def trim(preserve = false) if !preserve @value.sub!(/\A\s*([\s\S]*?)\s*\Z/, "\\1") return @value end nil end