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.
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#nodes ⇒ Object
Returns the value of attribute nodes.
Attributes included from Reportable
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, #set_doc!, #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
40 41 42 43 44 45 46 47 48 |
# File 'lib/duxml/doc/element.rb', line 40 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.
50 51 52 |
# File 'lib/duxml/doc/element.rb', line 50 def column @column end |
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
50 51 52 |
# File 'lib/duxml/doc/element.rb', line 50 def doc @doc end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
50 51 52 |
# File 'lib/duxml/doc/element.rb', line 50 def line @line end |
#nodes ⇒ Object
Returns the value of attribute nodes.
52 53 54 |
# File 'lib/duxml/doc/element.rb', line 52 def nodes @nodes end |