class Ayril::XMLNode
Constants
- URI
Public Class Methods
attributeWithName(name, stringValue: string)
click to toggle source
# File lib/ayril/xml_node.rb, line 64 def self.attributeWithName(name, stringValue: string) e = XMLElement.alloc.initWithName "r" e.setAttributesAsDictionary name => string (e.attributeForName name).tap { |a| a.detach } end
commentWithStringValue(string)
click to toggle source
# File lib/ayril/xml_node.rb, line 81 def self.commentWithStringValue(string) d = XMLDocument.alloc.initWithXMLString "<r><!--#{string}--></r>", options: 0, error: nil d.rootElement.childAtIndex(0).tap { |n| n.detach } end
document()
click to toggle source
XXX: Why raise NotImplementedError?
xmldocs with text nodes failed to parse and returned nil..?
def initWithKind(kind) raise NotImplementedError end def initWithKind(kind, options: options) raise NotImplementedError end
# File lib/ayril/xml_node.rb, line 36 def self.document XMLDocument.alloc end
documentWithRootElement(element)
click to toggle source
# File lib/ayril/xml_node.rb, line 40 def self.documentWithRootElement(element) XMLDocument.alloc.initWithRootElement element end
elementWithName(name)
click to toggle source
# File lib/ayril/xml_node.rb, line 44 def self.elementWithName(name) XMLElement.alloc.initWithName name end
textWithStringValue(string)
click to toggle source
# File lib/ayril/xml_node.rb, line 76 def self.textWithStringValue(string) d = XMLDocument.initWithXMLString "<r>#{string}</r>", options: 0, error: nil d.rootElement.childAtIndex(0).tap { |n| n.detach } end
Public Instance Methods
attr?()
click to toggle source
# File lib/ayril/xml_node.rb, line 108 def attr?; self.kind == NSXMLAttributeKind end
Also aliased as: attribute?
comment?()
click to toggle source
# File lib/ayril/xml_node.rb, line 113 def comment?; self.kind == NSXMLCommentKind end
doc?()
click to toggle source
# File lib/ayril/xml_node.rb, line 103 def doc?; self.kind == NSXMLDocumentKind end
dtd?()
click to toggle source
# File lib/ayril/xml_node.rb, line 115 def dtd?; self.kind == NSXMLDTDKind end
elem?()
click to toggle source
# File lib/ayril/xml_node.rb, line 105 def elem?; self.kind == NSXMLElementKind end
Also aliased as: element?
kind?(kind)
click to toggle source
def self.namespaceWithName(name, stringValue: string) raise NotImplementedError end def self.DTDNodeWithXMLString(string) raise NotImplementedError end def self.predefinedNamespaceForPrefix(prefix) raise NotImplementedError end def self.processingInstructionWithName(name, stringValue: string) raise NotImplementedError end
# File lib/ayril/xml_node.rb, line 91 def kind?(kind) return self.kind == kind if kind.kind_of? Fixnum kind = kind.to_sym kinds = %w(invalid document element attribute namespace processing_instruction comment text DTD).invoke(:to_sym) if kinds.include? kind camelcase = kind.to_s.capitalize.gsub(/_([a-z])/) { |m| m[1].upcase } return self.kind == Object.const_get(:"NSXML#{camelcase}Kind") end false end
Also aliased as: type?
namespace?()
click to toggle source
# File lib/ayril/xml_node.rb, line 111 def namespace?; self.kind == NSXMLNamespaceKind end
pi?()
click to toggle source
# File lib/ayril/xml_node.rb, line 112 def pi?; self.kind == NSXMLProcessingInstructionKind end
text?()
click to toggle source
# File lib/ayril/xml_node.rb, line 114 def text?; self.kind == NSXMLTextKind end