class Glimmer::XML::Node

Attributes

attributes[RW]

TODO change is_name_space to name_space?

children[RW]

TODO change is_name_space to name_space?

contents[RW]

TODO change is_name_space to name_space?

is_attribute[RW]

TODO change is_name_space to name_space?

is_name_space[RW]

TODO change is_name_space to name_space?

name[RW]

TODO change is_name_space to name_space?

name_space[RW]

TODO change is_name_space to name_space?

parent[RW]

TODO change is_name_space to name_space?

Public Class Methods

new(parent, name, attributes, &contents) click to toggle source
# File lib/glimmer/xml/node.rb, line 34
def initialize(parent, name, attributes, &contents)
  @is_name_space = false
  @children = []
  @parent = parent
  if attributes.is_a?(Array)
    attributes = attributes.compact
    hash_attributes = attributes.last.is_a?(Hash) ? attributes.delete(attributes.last) : {}
    hash_attributes = attributes.reduce(hash_attributes) do |hash, attribute|
      hash.merge(attribute => nil)
    end
    attributes = hash_attributes
  end
  if (parent and parent.is_name_space)
    @name_space = parent
    @parent = @name_space.parent
  end
  @parent.children << self if @parent
  @name = name
  @contents = contents
  @attributes = attributes
  if @attributes
    @attributes.each_key do |attribute|
      if attribute.is_a?(Node)
        attribute.is_attribute = true
        attribute.parent.children.delete(attribute) if attribute.parent
        attribute.parent = nil #attributes do not usually have parents
      end
    end
    Glimmer::Config.logger&.debug(attributes)
  end
end

Public Instance Methods

id() click to toggle source

override Object default id method and route it to Glimmer engine

# File lib/glimmer/xml/node.rb, line 95
def id
  method_missing(:id)
end
method_missing(symbol, *args, &block) click to toggle source
Calls superclass method
# File lib/glimmer/xml/node.rb, line 66
def method_missing(symbol, *args, &block)
  @is_name_space = true
  parent.children.delete(self) if parent
  Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::XML::XmlExpression.new, name, attributes) {@tag = super}
  @tag
end
name_space_context?() click to toggle source
# File lib/glimmer/xml/node.rb, line 73
def name_space_context?
  attributes[:_name_space_context]
end
rubyize(text) click to toggle source
# File lib/glimmer/xml/node.rb, line 88
def rubyize(text)
  text = text.gsub(/[}]/, '"}')
  text = text.gsub(/[{]/, '{"')
  text = text.gsub(/[#]/, '')
end
text_command(text) click to toggle source
# File lib/glimmer/xml/node.rb, line 84
def text_command(text)
  "text \"#{text}\""
end
to_s()
Alias for: to_xml
to_xml() click to toggle source
# File lib/glimmer/xml/node.rb, line 77
def to_xml
  xml_visitor = XmlVisitor.new
  DepthFirstSearchIterator.new(self, xml_visitor).iterate
  xml_visitor.document
end
Also aliased as: to_s