Class: XML::DOM::CharacterData

Inherits:
Node
  • Object
show all
Defined in:
lib/xml/dom/core.rb,
lib/xml/dom2/characterdata.rb

Overview

Class XML::DOM::CharacterData

superclass

Node

Direct Known Subclasses

Comment, Text

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

Methods inherited from Node

#+, #<=>, #==, #[], #[]=, #__collectAncestorNS, #__collectDescendatNS, #__sibling, #_ancestor, #_checkNode, #_child, #_descendant, #_following, #_fsibling, #_getChildIndex, #_getMyLocation, #_getMyLocationInXPath, #_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, #dump, #each, #firstChild, #getDigest, #getNodesByXPath, #getNodesByXPointer, #hasAttributes, #hasChildNodes, #insertBefore, #inspect, #isSupported, #lastChild, #localname, #makeXPath, #makeXPointer, #namespaceURI, #nextSibling, #nodeName, #nodeType, #ownerDocument, #ownerDocument=, #parentNode, #parentNode=, #prefix, #prefix=, #previousSibling, #removeChild, #replaceChild, #to_s, #trim

Constructor Details

#initialize(text = nil) ⇒ CharacterData

new(text)

text: String


2296
2297
2298
2299
2300
# File 'lib/xml/dom/core.rb', line 2296

def initialize(text = nil)
  super()
  raise "parameter error" if !text
  @value = text
end

Instance Method Details

#appendData(str) ⇒ Object

DOM


2360
2361
2362
# File 'lib/xml/dom/core.rb', line 2360

def appendData(str)
  @value << str
end

#cloneNode(deep = true) ⇒ Object

DOM


2414
2415
2416
# File 'lib/xml/dom/core.rb', line 2414

def cloneNode(deep = true)
  super(deep, @value.dup)
end

#dataObject

DOM


2311
2312
2313
# File 'lib/xml/dom/core.rb', line 2311

def data
  @value.dup
end

#data=(p) ⇒ Object

DOM


2322
2323
2324
# File 'lib/xml/dom/core.rb', line 2322

def data=(p)
    @value = p
end

#deleteData(offset, count) ⇒ Object

DOM


2385
2386
2387
2388
2389
2390
# File 'lib/xml/dom/core.rb', line 2385

def deleteData(offset, count)
  if offset < 0 || offset > @value.length || count < 0
    raise DOMException.new(DOMException::INDEX_SIZE_ERR)
  end
  @value[offset, count] = ''
end

#insertData(offset, str) ⇒ Object

DOM


2371
2372
2373
2374
2375
2376
# File 'lib/xml/dom/core.rb', line 2371

def insertData(offset, str)
  if offset < 0 || offset > @value.length
    raise DOMException.new(DOMException::INDEX_SIZE_ERR)
  end
  @value[offset, 0] = str
end

#lengthObject

DOM


2333
2334
2335
# File 'lib/xml/dom/core.rb', line 2333

def length
  @value.length
end

#nodeValueObject

DOM


2426
2427
2428
# File 'lib/xml/dom/core.rb', line 2426

def nodeValue
  @value
end

#nodeValue=(p) ⇒ Object

DOM


2437
2438
2439
# File 'lib/xml/dom/core.rb', line 2437

def nodeValue=(p)
  @value = p
end

#replaceData(offset, count, str) ⇒ Object

DOM


2400
2401
2402
2403
2404
2405
# File 'lib/xml/dom/core.rb', line 2400

def replaceData(offset, count, str)
  if offset < 0 || offset > @value.length || count < 0
    raise DOMException.new(DOMException::INDEX_SIZE_ERR)
  end
  @value[offset, count] = str
end

#substringData(start, count) ⇒ Object

DOM


2344
2345
2346
2347
2348
2349
2350
2351
# File 'lib/xml/dom/core.rb', line 2344

def substringData(start, count)
  if start < 0 || start > @value.length || count < 0
    raise DOMException.new(DOMException::INDEX_SIZE_ERR)
  end
  ## if the sum of start and count > length,
  ##  return all characters to the end of the value.
  @value[start, count]
end