Module: REXML::Namespace

Includes:
XMLTokens
Included in:
Attribute, Element
Defined in:
lib/rexml/namespace.rb

Overview

Adds named attributes to an object.

Constant Summary collapse

NAMESPLIT =
/^(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})/u

Constants included from XMLTokens

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#expanded_nameObject (readonly)

The name of the object, valid if set



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

def expanded_name
  @expanded_name
end

#nameObject Also known as: local_name

The name of the object, valid if set



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

def name
  @name
end

#prefixObject

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



11
12
13
# File 'lib/rexml/namespace.rb', line 11

def prefix
  @prefix
end

Instance Method Details

#fully_expanded_nameObject

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



53
54
55
56
57
# File 'lib/rexml/namespace.rb', line 53

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

Returns:

  • (Boolean)


39
40
41
42
43
44
45
46
47
# File 'lib/rexml/namespace.rb', line 39

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