Class: Ayril::XMLDocument

Inherits:
NSXMLDocument
  • Object
show all
Includes:
Ayril::XMLNode::NodeManipulation, Ayril::XMLNode::NodeTraversal
Defined in:
lib/ayril/xml_document.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Ayril::XMLNode::NodeTraversal

#adjacent, #ancestors, #at, #contains?, #descendant_of?, #descendants, #down, #empty?, #first_descendant, #immediate_descendants, #next, #next_element_sibling, #next_siblings, #previous, #previous_element_sibling, #previous_siblings, #recursively_collect, #select, #select_by_xpath, #siblings, #up

Methods included from Ayril::XMLNode::NodeManipulation

#clean_whitespace, #inner_html, #remove, #replace, #update

Class Method Details

.new(data, error = nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ayril/xml_document.rb', line 26

def self.new(data, error=nil)
  path = data.dup
  path = NSURL.fileURLWithPath data.path if data.kind_of? File
  if path.kind_of? NSURL
    XMLDocument.alloc.initWithContentsOfURL path, options: 0, error: error
  elsif path.kind_of? XMLElement
    XMLDocument.alloc.initWithRootElement path
  elsif path.kind_of? String
    XMLDocument.alloc.initWithXMLString path, options: 0, error: error
  end
end

.replacementClassForClass(currentClass) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/ayril/xml_document.rb', line 38

def self.replacementClassForClass(currentClass)
  return {
    NSXMLNode     => XMLNode,
    NSXMLElement  => XMLElement,
    NSXMLDocument => XMLDocument,
    NSXMLDTD      => XMLDTD,
    NSXMLDTDNode  => XMLDTDNode
  }[currentClass]
end

Instance Method Details

#inspectObject



51
52
53
# File 'lib/ayril/xml_document.rb', line 51

def inspect
  "#<#{self.class}:0x#{self.object_id.to_s(16)}>"
end