Class: Duxml::Element
- 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
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#nodes ⇒ Object
Returns the value of attribute nodes.
Attributes included from Reportable
Attributes included from Duxml
Attributes included from Saxer
Instance Method Summary collapse
-
#initialize(name, _line_or_content = nil, _col_or_children = nil) ⇒ Element
constructor
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.
Methods included from ElementGuts
#<<, #[], #[]=, #abstract?, #add, #dclone, #delete, #description, #each, #history, #inspect, #name_space, #sclone, #stub, #text?, #to_s, #traverse
Methods included from LazyOx
Methods included from Reportable
Methods included from Duxml
Methods included from Saxer
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
#column ⇒ Object (readonly)
Returns the value of attribute column.
40 41 42 |
# File 'lib/duxml/doc/element.rb', line 40 def column @column end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
40 41 42 |
# File 'lib/duxml/doc/element.rb', line 40 def line @line end |
#nodes ⇒ Object
Returns the value of attribute nodes.
42 43 44 |
# File 'lib/duxml/doc/element.rb', line 42 def nodes @nodes end |