123456789_123456789_123456789_123456789_123456789_

Module: REXML::Namespace

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, XMLTokens
Defined in: lib/rexml/namespace.rb

Overview

Adds named attributes to an object.

Constant Summary

XMLTokens - Included

NAME, NAMECHAR, NAME_CHAR, NAME_START_CHAR, NAME_STR, NCNAME_STR, NMTOKEN, NMTOKENS, REFERENCE

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#expanded_name (readonly)

The name of the object, valid if set

[ GitHub ]

  
# File 'lib/rexml/namespace.rb', line 8

attr_reader :name, :expanded_name

#local_name (readonly)

Alias for #name.

[ GitHub ]

  
# File 'lib/rexml/namespace.rb', line 38

alias :local_name :name

#name (rw) Also known as: #local_name

The name of the object, valid if set

[ GitHub ]

  
# File 'lib/rexml/namespace.rb', line 8

attr_reader :name, :expanded_name

#name=(name) (rw)

Sets the name and the expanded name

[ GitHub ]

  
# File 'lib/rexml/namespace.rb', line 15

def name=( name )
  @expanded_name = name
  name =~ NAMESPLIT
  if $1
    @prefix = $1
  else
    @prefix = ""
    @namespace = ""
  end
  @name = $2
end

#prefix (rw)

The expanded name of the object, valid if name is set

[ GitHub ]

  
# File 'lib/rexml/namespace.rb', line 10

attr_accessor :prefix

Instance Method Details

#fully_expanded_name

Fully expand the name, even if the prefix wasn't specified in the source file.

[ GitHub ]

  
# File 'lib/rexml/namespace.rb', line 42

def fully_expanded_name
  ns = prefix
  return "#{ns}:#@name" if ns.size > 0
  return @name
end

#has_name?(other, ns = nil) ⇒ Boolean

Compares names optionally WITH namespaces

[ GitHub ]

  
# File 'lib/rexml/namespace.rb', line 28

def has_name?( other, ns=nil )
  if ns
    return (namespace() == ns and name() == other)
  elsif other.include? ":"
    return fully_expanded_name == other
  else
    return name == other
  end
end