class XML::DOM::Attribute

Class XML::DOM::Attr

superclass

Node

Class XML::DOM::Attr

superclass

Node

Public Class Methods

new(name = nil, *text) click to toggle source

Class Methods

Calls superclass method XML::DOM::Node::new
# File lib/xml/dom/core.rb, line 1774
def initialize(name = nil, *text)
  super(text)
  raise "parameter error" if !name
  @name =  name
  @name.freeze
end

Public Instance Methods

_checkNode(node) click to toggle source
# File lib/xml/dom/core.rb, line 1903
def _checkNode(node)
  unless node.nodeType == TEXT_NODE ||
      node.nodeType == ENTITY_REFERENCE_NODE
    raise DOMException.new(DOMException::HIERARCHY_REQUEST_ERR)
  end
end
cloneNode(deep = true) click to toggle source
Calls superclass method XML::DOM::Node#cloneNode
# File lib/xml/dom/core.rb, line 1872
def cloneNode(deep = true)
  super(deep, @name)
end
dump(depth = 0) click to toggle source
# File lib/xml/dom/core.rb, line 1860
def dump(depth = 0)
  print ' ' * depth * 2
  print "// #{self.to_s}\n"
end
getDigest(algorithm = Digest::MD5, force = false) click to toggle source
# File lib/xml/dom/digest.rb, line 59
def getDigest(algorithm = Digest::MD5, force = false)
  (!force && @digest) ||
    @digest = algorithm.digest([ATTRIBUTE_NODE].pack("N") +
                               DOM.tou16(nodeName) + "\0\0" + DOM.tou16(nodeValue))
end
localname() click to toggle source
DOM2
# File lib/xml/dom2/attr.rb, line 198
def localname; @localname; end
makeXPath() click to toggle source
# File lib/xml/dom2/xpath.rb, line 388
def makeXPath
  '@' + nodeName
end
name()
Alias for: nodeName
namespaceURI() click to toggle source
DOM2
# File lib/xml/dom2/attr.rb, line 180
def namespaceURI; @uri; end
nodeName() click to toggle source
# File lib/xml/dom/core.rb, line 1801
def nodeName
  @name
end
Also aliased as: name, name
nodeType() click to toggle source

Methods

# File lib/xml/dom/core.rb, line 1790
def nodeType
  ATTRIBUTE_NODE
end
nodeValue() click to toggle source
# File lib/xml/dom/core.rb, line 1812
def nodeValue
  ret = ""
  @children.each do |child|
    ret << child.nodeValue
  end if @children
  ret
end
Also aliased as: value, value
nodeValue=(text) click to toggle source
# File lib/xml/dom/core.rb, line 1827
def nodeValue=(text)
  self.childNodes = [text]
end
Also aliased as: value=, value=
ownerElement() click to toggle source
DOM2
# File lib/xml/dom2/attr.rb, line 201
def ownerElement; @ownerElement; end
ownerElement=(elem) click to toggle source
# File lib/xml/dom2/attr.rb, line 202
def ownerElement=(elem); @ownerElement = elem; end
prefix() click to toggle source
DOM2
# File lib/xml/dom2/attr.rb, line 183
def prefix; @prefix; end
prefix=(prefix) click to toggle source
DOM2
# File lib/xml/dom2/attr.rb, line 186
def prefix=(prefix);
  ## to be checked

  @ownerElement.removeAttributeNode(self) if @ownerElement
  @prefix = prefix
  @name = @prefix + ':' + @localname
  @ownerElement.setAttributeNode(self) if @ownerElement
  @prefix.freeze
  @name.freeze
end
specified() click to toggle source
DOM
# File lib/xml/dom/core.rb, line 1900
def specified; @specified; end
specified=(is_specified) click to toggle source
# File lib/xml/dom/core.rb, line 1901
def specified=(is_specified); @specified = is_specified; end
to_s() click to toggle source
# File lib/xml/dom/core.rb, line 1836
def to_s
  value = ""
  nodeValue.each_byte do |code|
    case code
    when 9, 10, 13
      value << sprintf("&#x%X;", code)
    when ?&
      value << "&amp;"
    when ?"
      value << "&quot;"
    when ?<
      value << "&lt;"
    else
      value << code
    end
  end
  "#{@name}=\"#{value}\""
end
value()
Alias for: nodeValue
value=(text)
Alias for: nodeValue=