Class: REXML::Light::Node (Ruby 2.3.7)
Description: Class : REXML::Light::Node - Ruby 2.3.7

- Home
- Core 2.3.7
- Std-lib 2.3.7
- Downloads

Support for the Ruby 2.3 series has ended. See here for reference.

### Home Classes Methods

### In Files

- rexml/light/node.rb

### Parent

Object

### Methods

- ::new
- #<<
- #=~
- #[]
- #[]=
- #children
- #each
- #has_name?
- #local_name
- #local_name=
- #name
- #name=
- #namespace
- #namespace=
- #node_type
- #parent
- #parent=
- #prefix
- #root
- #size
- #text=
- #to_s

### Class/Module Index

Quicksearch

- Array
- Fixnum
- Float
- Object
- REXML
- REXML::AttlistDecl
- REXML::Attribute
- REXML::Attributes
- REXML::CData
- REXML::Child
- REXML::Comment
- REXML::DTD
- REXML::DTD::AttlistDecl
- REXML::DTD::ElementDecl
- REXML::DTD::EntityDecl
- REXML::DTD::NotationDecl
- REXML::DTD::Parser
- REXML::Declaration
- REXML::DocType
- REXML::Document
- REXML::Element
- REXML::ElementDecl
- REXML::Elements
- REXML::Encoding
- REXML::Entity
- REXML::EntityConst
- REXML::ExternalEntity
- REXML::Formatters
- REXML::Formatters::Default
- REXML::Formatters::Pretty
- REXML::Formatters::Transitive
- REXML::Functions
- REXML::IOSource
- REXML::Instruction
- REXML::Light
- REXML::Light::Node
- REXML::Namespace
- REXML::Node
- REXML::NotationDecl
- REXML::Output
- REXML::Parent
- REXML::ParseException
- REXML::Parsers
- REXML::Parsers::BaseParser
- REXML::Parsers::LightParser
- REXML::Parsers::PullEvent
- REXML::Parsers::PullParser
- REXML::Parsers::SAX2Parser
- REXML::Parsers::StreamParser
- REXML::Parsers::TreeParser
- REXML::Parsers::UltraLightParser
- REXML::Parsers::XPathParser
- REXML::QuickPath
- REXML::SAX2Listener
- REXML::Security
- REXML::Source
- REXML::SourceFactory
- REXML::StreamListener
- REXML::SyncEnumerator
- REXML::Text
- REXML::UndefinedNamespaceException
- REXML::Validation
- REXML::Validation::Choice
- REXML::Validation::Event
- REXML::Validation::Interleave
- REXML::Validation::OneOrMore
- REXML::Validation::Optional
- REXML::Validation::Ref
- REXML::Validation::RelaxNG
- REXML::Validation::Sequence
- REXML::Validation::State
- REXML::Validation::ValidationException
- REXML::Validation::Validator
- REXML::Validation::ZeroOrMore
- REXML::XMLDecl
- REXML::XMLTokens
- REXML::XPath
- REXML::XPathParser
- Symbol

No matching classes.

# REXML::Light::Node

Represents a tagged XML element. Elements are characterized by having children, attributes, and names, and can themselves be children.

### Constants

NAMESPLIT
PARENTS

### Public Class Methods

new(node=nil) click to toggle source

Create a new element.

                   # File rexml/light/node.rb, line 20
    def initialize node=nil
      @node = node
      if node.kind_of? String
        node = [ :text, node ]
      elsif node.nil?
        node = [ :document, nil, nil ]
      elsif node[0] == :start_element
        node[0] = :element
      elsif node[0] == :start_doctype
        node[0] = :doctype
      elsif node[0] == :start_document
        node[0] = :document
      end
    end

### Public Instance Methods

<<(element) click to toggle source

Append a child to this element, optionally under a provided namespace. The namespace argument is ignored if the element argument is an Element object. Otherwise, the element argument is a string, the namespace (if provided) is the namespace the element is created in.

                   # File rexml/light/node.rb, line 121
    def << element
      if node_type() == :text
        at(-1) << element
      else
        newnode = Node.new( element )
        newnode.parent = self
        self.push( newnode )
      end
      at(-1)
    end

=~( path ) click to toggle source

                   # File rexml/light/node.rb, line 97
    def =~( path )
      XPath.match( self, path )
    end

[]( reference, ns=nil ) click to toggle source

                   # File rexml/light/node.rb, line 85
    def []( reference, ns=nil )
      if reference.kind_of? String
        pfx = ''
        pfx = "#{prefix(ns)}:" if ns
        at(3)["#{pfx}#{reference}"]
      elsif reference.kind_of? Range
        _old_get( Range.new(4+reference.begin, reference.end, reference.exclude_end?) )
      else
        _old_get( 4+reference )
      end
    end

[]=( reference, ns, value=nil ) click to toggle source

Doesn't handle namespaces yet

                   # File rexml/light/node.rb, line 102
    def []=( reference, ns, value=nil )
      if reference.kind_of? String
        value = ns unless value
        at( 3 )[reference] = value
      elsif reference.kind_of? Range
        _old_put( Range.new(3+reference.begin, reference.end, reference.exclude_end?), ns )
      else
        if value
          _old_put( 4+reference, ns, value )
        else
          _old_put( 4+reference, ns )
        end
      end
    end

children() click to toggle source

                   # File rexml/light/node.rb, line 150
    def children
      self
    end

each() click to toggle source

                   # File rexml/light/node.rb, line 43
    def each
      size.times { |x| yield( at(x+4) ) }
    end

has_name?( name, namespace = '' ) click to toggle source

                   # File rexml/light/node.rb, line 146
    def has_name?( name, namespace = '' )
      at(3) == name and namespace() == namespace
    end

local_name() click to toggle source

                   # File rexml/light/node.rb, line 61
    def local_name
      namesplit
      @name
    end

local_name=( name_str ) click to toggle source

                   # File rexml/light/node.rb, line 66
    def local_name=( name_str )
      _old_put( 1, "#@prefix:#{name_str}" )
    end

name() click to toggle source

                   # File rexml/light/node.rb, line 47
    def name
      at(2)
    end

name=( name_str, ns=nil ) click to toggle source

                   # File rexml/light/node.rb, line 51
    def name=( name_str, ns=nil )
      pfx = ''
      pfx = "#{prefix(ns)}:" if ns
      _old_put(2, "#{pfx}#{name_str}")
    end

namespace( prefix=prefix() ) click to toggle source

                   # File rexml/light/node.rb, line 74
    def namespace( prefix=prefix() )
      namespace_of( self, prefix )
    end

namespace=( namespace ) click to toggle source

                   # File rexml/light/node.rb, line 78
    def namespace=( namespace )
      @prefix = prefix( namespace )
      pfx = ''
      pfx = "#@prefix:" if @prefix.size > 0
      _old_put(1, "#{pfx}#@name")
    end

node_type() click to toggle source

                   # File rexml/light/node.rb, line 132
    def node_type
      _old_get(0)
    end

parent() click to toggle source

                   # File rexml/light/node.rb, line 154
    def parent
      at(1)
    end

parent=( node ) click to toggle source

                   # File rexml/light/node.rb, line 57
    def parent=( node )
      _old_put(1,node)
    end

prefix( namespace=nil ) click to toggle source

                   # File rexml/light/node.rb, line 70
    def prefix( namespace=nil )
      prefix_of( self, namespace )
    end

root() click to toggle source

                   # File rexml/light/node.rb, line 141
    def root
      context = self
      context = context.at(1) while context.at(1)
    end

size() click to toggle source

                   # File rexml/light/node.rb, line 35
    def size
      if PARENTS.include? @node[0]
        @node[-1].size
      else
        0
      end
    end

text=( foo ) click to toggle source

                   # File rexml/light/node.rb, line 136
    def text=( foo )
      replace = at(4).kind_of?(String)? 1 : 0
      self._old_put(4,replace, normalizefoo)
    end

to_s() click to toggle source

                   # File rexml/light/node.rb, line 158
    def to_s

    end