Module: MobyUtil::XML::Nokogiri::Node
- Includes:
- Abstraction
- Defined in:
- lib/tdriver/util/xml/parsers/nokogiri/node.rb
Overview
behaviour
Instance Method Summary collapse
-
#<=>(object) ⇒ Object
TODO: document me.
-
#==(object) ⇒ Object
(also: #eql?)
TODO: document me.
-
#[](value) ⇒ Object
TODO: document me.
-
#[]=(name, value) ⇒ Object
TODO: document me.
-
#add_previous_sibling(other) ⇒ Object
TODO: document me.
-
#at_xpath(xpath_query, *args, &block) ⇒ Object
TODO: document me.
-
#attribute(attr_name) ⇒ Object
TODO: document me.
-
#attributes ⇒ Object
TODO: document me.
-
#blank? ⇒ Boolean
TODO: document me.
-
#children ⇒ Object
TODO: document me.
-
#content ⇒ Object
(also: #text, #inner_text)
TODO: document me.
-
#each(&block) ⇒ Object
TODO: document me.
-
#inner_html ⇒ Object
(also: #inner_xml)
TODO: document me.
-
#parent ⇒ Object
TODO: document me.
-
#remove ⇒ Object
TODO: document me.
-
#replace(other) ⇒ Object
TODO: document me.
-
#to_s ⇒ Object
TODO: document me.
-
#xpath(xpath_query, *args, &block) ⇒ Object
TODO: document me.
Methods included from Abstraction
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class MobyUtil::XML::Nokogiri::Abstraction
Instance Method Details
#<=>(object) ⇒ Object
TODO: document me
57 58 59 60 61 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 57 def <=>( object ) cache( :<=>, object.object_id ){ @xml <=> object.xml } end |
#==(object) ⇒ Object Also known as: eql?
TODO: document me
47 48 49 50 51 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 47 def ==( object ) cache( :==, object.object_id ){ @xml.content == object.xml.content } end |
#[](value) ⇒ Object
TODO: document me
31 32 33 34 35 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 31 def []( value ) cache( :[], value ){ @xml[ value ] } end |
#[]=(name, value) ⇒ Object
TODO: document me
38 39 40 41 42 43 44 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 38 def []=( name, value ) clear_cache @xml[ name ] = value end |
#add_previous_sibling(other) ⇒ Object
TODO: document me
64 65 66 67 68 69 70 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 64 def add_previous_sibling( other ) clear_cache @xml.add_previous_sibling( other.xml ) end |
#at_xpath(xpath_query, *args, &block) ⇒ Object
TODO: document me
189 190 191 192 193 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 189 def at_xpath( xpath_query, *args, &block ) cache( :at_xpath, xpath_query ){ node_object( @xml.at_xpath( xpath_query, *args, &block ) ) } end |
#attribute(attr_name) ⇒ Object
TODO: document me
73 74 75 76 77 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 73 def attribute( attr_name ) cache( :attribute, attr_name ){ _attribute( @xml.attribute( attr_name ) ) } end |
#attributes ⇒ Object
TODO: document me
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 80 def attributes cache( :attributes, :value ){ # return hash of attributes #Hash[ @xml.attribute_nodes.collect{ | node | # [ node.node_name, node.value.to_s ] } #] # approx. 20% faster @xml.attribute_nodes.inject({}){ | result, node | result[ node.node_name ] = node.value; result } } end |
#blank? ⇒ Boolean
TODO: document me
97 98 99 100 101 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 97 def blank? cache( :blank?, :value ){ @xml.blank? } end |
#children ⇒ Object
TODO: document me
104 105 106 107 108 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 104 def children cache( :children, :value ){ node_object( @xml.children ) } end |
#content ⇒ Object Also known as: text, inner_text
TODO: document me
111 112 113 114 115 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 111 def content cache( :content, :value ){ @xml.content } end |
#each(&block) ⇒ Object
TODO: document me
122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 122 def each( &block ) # iterate each attribute @xml.each{ | element | yield( cache( :each, element ){ node_object( element ) } ) } nil end |
#inner_html ⇒ Object Also known as: inner_xml
TODO: document me
136 137 138 139 140 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 136 def inner_html cache( :inner_html, :value ){ @xml.inner_html } end |
#parent ⇒ Object
TODO: document me
153 154 155 156 157 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 153 def parent cache( :parent, :value ){ node_object( @xml.parent ) } end |
#remove ⇒ Object
TODO: document me
160 161 162 163 164 165 166 167 168 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 160 def remove clear_cache @xml.remove self end |
#replace(other) ⇒ Object
TODO: document me
171 172 173 174 175 176 177 178 179 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 171 def replace( other ) clear_cache @xml.replace( other.xml ) self end |
#to_s ⇒ Object
TODO: document me
146 147 148 149 150 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 146 def to_s cache( :to_s, :value ){ @xml.to_s } end |
#xpath(xpath_query, *args, &block) ⇒ Object
TODO: document me
182 183 184 185 186 |
# File 'lib/tdriver/util/xml/parsers/nokogiri/node.rb', line 182 def xpath( xpath_query, *args, &block ) cache( :xpath, xpath_query ){ node_object( @xml.xpath( xpath_query, *args, &block ) ) } end |