Class: Duxml::Element

Inherits:
Ox::Element
  • Object
show all
Includes:
ElementGuts
Defined in:
lib/duxml/doc/element.rb

Overview

basic component of XML file that can possess attributes and take sub Elements or String content

Instance Attribute Summary collapse

Attributes included from Reportable

#observer_peers

Attributes included from Duxml

#doc

Attributes included from Saxer

#io

Instance Method Summary collapse

Methods included from ElementGuts

#<<, #[], #[]=, #abstract?, #add, #dclone, #delete, #description, #each, #history, #inspect, #name_space, #sclone, #stub, #text?, #to_s, #traverse

Methods included from LazyOx

#method_missing

Methods included from Reportable

#add_observer

Methods included from Duxml

#load, #log, #save, #validate

Methods included from Saxer

#sax

Constructor Details

#initialize(name, _line_or_content = nil, _col_or_children = nil) ⇒ Element

operates in two modes:

  • from Ruby

  • from file

in file mode, args provide Element’s line and column location then freezes each Fixnum so it cannot be overwritten in Ruby mode, args are some combination of new attributes/values and/or child nodes (text or XML) with which to initialize this node



30
31
32
33
34
35
36
37
38
# File 'lib/duxml/doc/element.rb', line 30

def initialize(name, _line_or_content=nil, _col_or_children=nil)
  super name
  @line = _line_or_content if _line_or_content.respond_to?(:%)
  _line_or_content.each do |k,v| self[k] = v end if _line_or_content.respond_to?(:key)
  @nodes = NodeSet.new(self, _line_or_content) if _line_or_content.respond_to?(:pop) && _col_or_children.nil?
  @column = _col_or_children if _col_or_children.respond_to?(:%)
  @nodes = NodeSet.new(self, _col_or_children) if _col_or_children.respond_to?(:pop)
  @nodes = NodeSet.new(self) if @nodes.empty?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Duxml::LazyOx

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



40
41
42
# File 'lib/duxml/doc/element.rb', line 40

def column
  @column
end

#lineObject (readonly)

Returns the value of attribute line.



40
41
42
# File 'lib/duxml/doc/element.rb', line 40

def line
  @line
end

#nodesObject

Returns the value of attribute nodes.



42
43
44
# File 'lib/duxml/doc/element.rb', line 42

def nodes
  @nodes
end