Class: LibXML::XML::Attr

### Home Classes Methods

### In Files

- lib/libxml/attr.rb

### Parent

Object

### Methods

- #child?
- #doc?
- #each
- #each_attr
- #each_sibling
- #last?
- #namespaces
- #next?
- #node_type_name
- #ns?
- #parent?
- #prev?
- #siblings
- #to_a
- #to_h
- #to_s

### Included Modules

- Enumerable

### Class/Module Index

Quicksearch

- LibXML
- LibXML::XML
- LibXML::XML::Attr
- LibXML::XML::AttrDecl
- LibXML::XML::Attributes
- LibXML::XML::Document
- LibXML::XML::Error
- LibXML::XML::HTMLParser
- LibXML::XML::Namespace
- LibXML::XML::Namespaces
- LibXML::XML::Node
- LibXML::XML::Parser
- LibXML::XML::Reader
- LibXML::XML::SaxParser
- LibXML::XML::SaxParser::Callbacks
- LibXML::XML::SaxParser::VerboseCallbacks
- LibXML::XML::Schema
- LibXML::XML::Schema::Attribute
- LibXML::XML::Schema::Element
- LibXML::XML::Schema::Namespaces
- LibXML::XML::Schema::Type
- LibXML::XML::Schema::Types
- LibXML::XML::XPath
- LibXML::XML::XPath::Object
- Object

No matching classes.

# LibXML::XML::Attr

### Public Instance Methods

child? → (true|false) click to toggle source

Returns whether this attribute has child attributes.

    # File lib/libxml/attr.rb, line 12
    def child?
      not self.children.nil?
    end

doc? → (true|false) click to toggle source

Determine whether this attribute is associated with an XML::Document.

    # File lib/libxml/attr.rb, line 21
    def doc?
      not self.doc.nil?
    end

each(&blk) click to toggle source
Alias for: each_sibling
each_attr(&blk) click to toggle source
Alias for: each_sibling
each_sibling(&blk) click to toggle source

    # File lib/libxml/attr.rb, line 96
    def each_sibling(&blk)
      siblings(self,&blk)
    end

Also aliased as: each_attr, each
last? → (true|false) click to toggle source

Determine whether this is the last attribute.

    # File lib/libxml/attr.rb, line 29
    def last?
      self.last.nil?
    end

namespacess → XML::Namespaces click to toggle source

Returns this node's XML::Namespaces object, which is used to access the namespaces associated with this node.

    # File lib/libxml/attr.rb, line 56
    def namespaces
      @namespaces ||= XML::Namespaces.new(self)
    end

next? → (true|false) click to toggle source

Determine whether there is a next attribute.

    # File lib/libxml/attr.rb, line 37
    def next?
      not self.next.nil?
    end

node_type_name() click to toggle source

Returns this node's type name

    # File lib/libxml/attr.rb, line 78
    def node_type_name
      if node_type == Node::ATTRIBUTE_NODE
        'attribute'
      else
        raise(UnknownType, "Unknown node type: %n", node.node_type);
      end
    end

ns? → (true|false) click to toggle source

Determine whether this attribute has an associated namespace.

    # File lib/libxml/attr.rb, line 46
    def ns?
      not self.ns.nil?
    end

parent? → (true|false) click to toggle source

Determine whether this attribute has a parent.

    # File lib/libxml/attr.rb, line 65
    def parent?
      not self.parent.nil?
    end

prev? → (true|false) click to toggle source

Determine whether there is a previous attribute.

    # File lib/libxml/attr.rb, line 73
    def prev?
      not self.prev.nil?
    end

siblings(node, &blk) click to toggle source

Iterates nodes and attributes

    # File lib/libxml/attr.rb, line 87
    def siblings(node, &blk)
      if n = node
        loop do
          blk.call(n)
          break unless n = n.next
        end
      end
    end

to_a() click to toggle source

    # File lib/libxml/attr.rb, line 110
    def to_a
      inject([]) do |ary,a|
        ary << [a.name, a.value]
        ary
      end
    end

to_h() click to toggle source

    # File lib/libxml/attr.rb, line 103
    def to_h
      inject({}) do |h,a|
        h[a.name] = a.value
        h
      end
    end

to_s() click to toggle source

    # File lib/libxml/attr.rb, line 117
    def to_s
      "#{name} = #{value}"
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.