Class: XML::Node
- Inherits:
-
Object
- Object
- XML::Node
- Includes:
- AssertXPath::CommonXPathExtensions
- Defined in:
- lib/assert_xpath.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#[](index) ⇒ Object
:nodoc:.
-
#attributes ⇒ Object
ERGO match??.
- #get_path(xpath) ⇒ Object (also: #/)
- #inner_text(interstitial = '') ⇒ Object
-
#method_missing(*args, &block) ⇒ Object
:nodoc:.
- #search(xpath, &block) ⇒ Object
- #text ⇒ Object
Methods included from AssertXPath::CommonXPathExtensions
#identifiable?, #raise_magic_member_not_found, #symbolic?, #tribute
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
:nodoc:
892 893 894 895 896 897 898 899 900 901 902 903 904 |
# File 'lib/assert_xpath.rb', line 892 def method_missing(*args, &block) #:nodoc: # ERGO use the define_method trick here symbol = args.shift.to_s symbol.sub!(/\!$/, '') kid = if symbol == '/' find_first('/') else find_first("./#{symbol}") end return _bequeath_attributes(kid).drill(&block) if kid raise_magic_member_not_found(symbol, caller) end |
Instance Method Details
#[](index) ⇒ Object
:nodoc:
881 882 883 |
# File 'lib/assert_xpath.rb', line 881 def [](index) #:nodoc: return attributes[index.to_s] || super end |
#attributes ⇒ Object
ERGO match??
875 876 877 878 879 |
# File 'lib/assert_xpath.rb', line 875 def attributes hash = {} each_attr{|attr| hash[attr.name] = attr.value } return hash # ERGO uh, was there a leaner way?? end |
#get_path(xpath) ⇒ Object Also known as: /
885 886 887 888 |
# File 'lib/assert_xpath.rb', line 885 def get_path(xpath) node = find_first(xpath.to_s) return _bequeath_attributes(node) if node end |
#inner_text(interstitial = '') ⇒ Object
869 870 871 872 873 |
# File 'lib/assert_xpath.rb', line 869 def inner_text(interstitial = '') array = [] self.find( 'descendant-or-self::text()' ).each{|x| array << x } return array.join(interstitial) end |
#search(xpath, &block) ⇒ Object
855 856 857 858 859 860 861 |
# File 'lib/assert_xpath.rb', line 855 def search(xpath, &block) if block find(xpath, "x:http://www.w3.org/1999/xhtml").each(&block) #find(xpath, &block) end return [find_first(xpath, "x:http://www.w3.org/1999/xhtml")] end |
#text ⇒ Object
863 864 865 866 867 |
# File 'lib/assert_xpath.rb', line 863 def text #p text? find_first('text()').to_s #text? ? content : '' end |