Class: OpenXml::Builder::Element

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/openxml/builder/element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Element



7
8
9
# File 'lib/openxml/builder/element.rb', line 7

def initialize(*args)
  super Ox::Element.new(*args)
end

Instance Attribute Details

#namespaceObject

Returns the value of attribute namespace.



4
5
6
# File 'lib/openxml/builder/element.rb', line 4

def namespace
  @namespace
end

#parentObject

Returns the value of attribute parent.



5
6
7
# File 'lib/openxml/builder/element.rb', line 5

def parent
  @parent
end

Instance Method Details

#[]=(attribute, value) ⇒ Object



11
12
13
14
15
# File 'lib/openxml/builder/element.rb', line 11

def []=(attribute, value)
  namespace_def = attribute.downcase.to_s.match /^xmlns(?:\:(?<prefix>.*))?$/
  add_namespace(namespace_def[:prefix], value.to_s) if namespace_def
  super
end

#ancestorsObject



29
30
31
32
33
# File 'lib/openxml/builder/element.rb', line 29

def ancestors
  parents = [self]
  parents << parent.ancestors unless parent.nil? || !parent.respond_to?(:ancestors)
  parents.flatten
end

#namespacesObject Also known as: namespace_definitions



24
25
26
# File 'lib/openxml/builder/element.rb', line 24

def namespaces
  @namespaces ||= []
end