Class: Nokogiri::XML::Node
Direct Known Subclasses
Instance Method Summary collapse
- #[]=(name, value) ⇒ Object
- #attr_set ⇒ Object
- #find_first(*paths) ⇒ Object
-
#nokogiri_xpath ⇒ Object
alias_method :attr_get, :[] def [](name) attr_get name.to_s end.
- #xpath(*paths) ⇒ Object (also: #find)
Instance Method Details
#[]=(name, value) ⇒ Object
9 10 11 12 |
# File 'lib/blather/core_ext/nokogiri.rb', line 9 def []=(name, value) name = name.to_s value.nil? ? remove_attribute(name) : attr_set(name, value.to_s) end |
#attr_set ⇒ Object
8 |
# File 'lib/blather/core_ext/nokogiri.rb', line 8 alias_method :attr_set, :[]= |
#find_first(*paths) ⇒ Object
29 30 31 |
# File 'lib/blather/core_ext/nokogiri.rb', line 29 def find_first(*paths) xpath(*paths).first end |
#nokogiri_xpath ⇒ Object
alias_method :attr_get, :[]
def [](name)
attr_get name.to_s
end
19 |
# File 'lib/blather/core_ext/nokogiri.rb', line 19 alias_method :nokogiri_xpath, :xpath |
#xpath(*paths) ⇒ Object Also known as: find
20 21 22 23 24 25 26 |
# File 'lib/blather/core_ext/nokogiri.rb', line 20 def xpath(*paths) paths[0] = paths[0].to_s if paths.size > 1 && (namespaces = paths.pop).is_a?(Hash) paths << namespaces.inject({}) { |h,v| h[v[0].to_s] = v[1]; h } end nokogiri_xpath *paths end |