Module: AssertXPath::CommonXPathExtensions
- Included in:
- Hpricot::Doc, Hpricot::Elem, REXML::Element, XML::Node
- Defined in:
- lib/assert_xpath.rb
Overview
:nodoc:
Instance Method Summary collapse
- #[](index) ⇒ Object
-
#identifiable?(str) ⇒ Boolean
ERGO self.
- #raise_magic_member_not_found(symbol, whats_caller_ERGO) ⇒ Object
- #symbolic?(index) ⇒ Boolean
-
#tribute(block) ⇒ Object
ERGO mock the YarWiki and run its tests locally!!!.
Instance Method Details
#[](index) ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/assert_xpath.rb', line 79 def[](index) if symbol = symbolic?(index) return attributes[symbol] if attributes.has_key? symbol raise_magic_member_not_found(symbol, caller) end return super # ERGO test this works? end |
#identifiable?(str) ⇒ Boolean
ERGO self. ?
95 96 97 |
# File 'lib/assert_xpath.rb', line 95 def identifiable?(str) # ERGO self. ? return str =~ /^ [[:alpha:]] [[:alnum:]_]* $/ix end |
#raise_magic_member_not_found(symbol, whats_caller_ERGO) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/assert_xpath.rb', line 88 def raise_magic_member_not_found(symbol, whats_caller_ERGO) raise AFE, # ERGO merge with other raiser(s) "missing attribute: `#{symbol}` in " + "<#{ name } #{ attributes.keys.join(' ') }>", whats_caller_ERGO end |
#symbolic?(index) ⇒ Boolean
75 76 77 |
# File 'lib/assert_xpath.rb', line 75 def symbolic?(index) return index.to_s if (index.kind_of? String or index.kind_of? Symbol) end |
#tribute(block) ⇒ Object
ERGO mock the YarWiki and run its tests locally!!!
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/assert_xpath.rb', line 101 def tribute(block) stash = {} # put back the ones we changed! if block varz = instance_variables attributes.each do |key, value| if identifiable?(key) # deal if the key ain't a valid variable key = "@#{ key }" stash[key] = instance_variable_get(key) if varz.include?(key) #p stash[key] instance_variable_set key, value end end return instance_eval(&block) end ensure # put them back! stash.each{|key, value| instance_variable_set(key, value) } end |