class Jaspion::Miya::Document
Constants
- FLAT
- TREE
Attributes
objects[RW]
Array with Miya::Object
objects
structure[RW]
Indicates if the elements should be a flat array or hierarchy
Public Class Methods
new(xml = nil, structure = TREE)
click to toggle source
Initializes a Document
object and parses the xml argument if present
# File lib/jaspion/miya/document.rb, line 16 def initialize(xml = nil, structure = TREE) @objects = [] @structure = structure return if xml.nil? parse(xml) end
Public Instance Methods
end_element_namespace(name, prefix = nil, uri = nil)
click to toggle source
Nokogiri Document
method
# File lib/jaspion/miya/document.rb, line 37 def end_element_namespace(name, prefix = nil, uri = nil) return if name.nil? return if @structure == FLAT return if @objects.length <= 1 last = @objects.delete(@objects.last) @objects.last.push_child(last) end
parse(xml)
click to toggle source
Replaces the current @objects variable
# File lib/jaspion/miya/document.rb, line 25 def parse(xml) @objects = [] parser = Nokogiri::XML::SAX::Parser.new(self) parser.parse(xml) raise 'Document cannot have more than one root element' if @objects.length > 1 end
start_element_namespace(name, attrs = [], prefix = nil, uri = nil, ns = [])
click to toggle source
Nokogiri Document
method
# File lib/jaspion/miya/document.rb, line 33 def start_element_namespace(name, attrs = [], prefix = nil, uri = nil, ns = []) end