Module: Moxml::Namespace

Includes:
Node
Defined in:
lib/moxml/namespace.rb

Constant Summary

Constants included from NodeBehavior

Moxml::NodeBehavior::TYPES

Constants included from XmlUtils

XmlUtils::VALID_ELEMENT_NAMES

Instance Attribute Summary

Attributes included from NodeBehavior

#context, #native, #parent_node

Instance Method Summary collapse

Methods included from Node

adapter, contract_module, contract_modules, node_type_map, wrap

Methods included from NodeBehavior

#adapter, #add_child, #add_next_sibling, #add_previous_sibling, #after, #ancestors, #at_xpath, #before, #blank?, #children, #clear_native_memo!, #content, #descendants, #digest, #document, #dup, #each, #each_node, #entity_bearing?, #find, #find_all, #first_child, #following_siblings, #has_children?, #identifier, #initialize, #invalidate_namespace_cache!, #last_child, #line_number, #materialize, #materialize_fields, #namespace, #namespaces, #next_sibling, #outer_xml, #parent, #path, #preceding_siblings, #previous_sibling, #prime_contract, #refresh_native!, #remove, #replace, #source_position, #text, #to_xml, #xpath

Methods included from XmlUtils

#encode_entities, #normalize_xml_value, #validate_comment_content, #validate_declaration_encoding, #validate_declaration_standalone, #validate_declaration_version, #validate_element_name, #validate_entity_reference_name, #validate_pi_target, #validate_prefix, #validate_uri

Instance Method Details

#==(other) ⇒ Object



15
16
17
# File 'lib/moxml/namespace.rb', line 15

def ==(other)
  other.is_a?(Namespace) && prefix == other.prefix && uri == other.uri
end

#default?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/moxml/namespace.rb', line 27

def default?
  prefix.nil? || prefix.to_s == "xmlns"
end

#namespace?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/moxml/namespace.rb', line 31

def namespace?
  true
end

#prefixObject



7
8
9
# File 'lib/moxml/namespace.rb', line 7

def prefix
  adapter.namespace_prefix(@native)
end

#to_sObject



19
20
21
22
23
24
25
# File 'lib/moxml/namespace.rb', line 19

def to_s
  if prefix && prefix != "xmlns"
    %(xmlns:#{prefix}="#{uri}")
  else
    %(xmlns="#{uri}")
  end
end

#uriObject



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

def uri
  adapter.namespace_uri(@native)
end