Class: LibXML::XML::Node
- Inherits:
-
Object
- Object
- LibXML::XML::Node
- Includes:
- Traverseable
- Defined in:
- lib/axml/libxml.rb
Instance Method Summary collapse
- #child ⇒ Object
- #find_children(name) ⇒ Object
- #find_first_child(name) ⇒ Object
- #find_first_descendant(name) ⇒ Object
- #old_child ⇒ Object
- #old_text? ⇒ Object
- #text ⇒ Object (also: #content)
- #text? ⇒ Boolean
-
#traverse(type = :pre, &block) ⇒ Object
full traversal from the initial node.
Instance Method Details
#child ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/axml/libxml.rb', line 63 def child kid = self.old_child return nil if kid.nil? while kid.old_text? kid = kid.old_child return nil if kid.nil? end kid end |
#find_children(name) ⇒ Object
76 77 78 |
# File 'lib/axml/libxml.rb', line 76 def find_children(name) find("child::#{name}") end |
#find_first_child(name) ⇒ Object
73 74 75 |
# File 'lib/axml/libxml.rb', line 73 def find_first_child(name) find_first("child::#{name}") end |
#find_first_descendant(name) ⇒ Object
79 80 81 |
# File 'lib/axml/libxml.rb', line 79 def find_first_descendant(name) find_first("descendant::#{name}") end |
#old_child ⇒ Object
38 |
# File 'lib/axml/libxml.rb', line 38 alias_method :old_child, :child |
#old_text? ⇒ Object
39 |
# File 'lib/axml/libxml.rb', line 39 alias_method :old_text?, :text? |
#text ⇒ Object Also known as: content
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/axml/libxml.rb', line 46 def text cont = self.old_content if cont == "" nil else cont end #kid = self.old_child #return nil unless kid ##p(kid.methods - Object.methods) #if kid.old_text? # kid.to_s #end end |
#text? ⇒ Boolean
42 43 44 |
# File 'lib/axml/libxml.rb', line 42 def text? self.old_child.old_text? end |
#traverse(type = :pre, &block) ⇒ Object
full traversal from the initial node
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/axml/libxml.rb', line 84 def traverse(type=:pre, &block) if type == :pre block.call(self) unless self.old_text? end children.each do |child| child.traverse(type, &block) end if type == :post block.call(self) unless self.old_text? end end |