Class: XML::Node

Inherits:
Object
  • Object
show all
Includes:
AssertXPath::CommonXPathExtensions
Defined in:
lib/assert_xpath.rb

Overview

:nodoc:

Instance Method Summary collapse

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:



918
919
920
921
922
923
924
925
926
927
928
929
930
# File 'lib/assert_xpath.rb', line 918

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:



907
908
909
# File 'lib/assert_xpath.rb', line 907

def [](index) #:nodoc:
  return attributes[index.to_s] || super
end

#attributesObject

ERGO match??



901
902
903
904
905
# File 'lib/assert_xpath.rb', line 901

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: /



911
912
913
914
# File 'lib/assert_xpath.rb', line 911

def get_path(xpath)
  node = find_first(xpath.to_s)
  return _bequeath_attributes(node)  if node
end

#inner_text(interstitial = '') ⇒ Object



895
896
897
898
899
# File 'lib/assert_xpath.rb', line 895

def inner_text(interstitial = '')
  array = []
  self.find( 'descendant-or-self::text()' ).each{|x| array << x }
  return array.join(interstitial)
end

#search(xpath, &block) ⇒ Object Also known as: each_element



880
881
882
883
884
885
886
# File 'lib/assert_xpath.rb', line 880

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

#textObject



889
890
891
892
893
# File 'lib/assert_xpath.rb', line 889

def text
#p text?
  find_first('text()').to_s
  #text? ? content : ''
end