diff options
Diffstat (limited to 'lib/rexml/functions.rb')
-rw-r--r-- | lib/rexml/functions.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/rexml/functions.rb b/lib/rexml/functions.rb index 7a2fb996a0..c09ffdeae7 100644 --- a/lib/rexml/functions.rb +++ b/lib/rexml/functions.rb @@ -67,11 +67,10 @@ module REXML if node_set == nil yield @@context[:node] if defined? @@context[:node].namespace else - if node_set.namespace - yield node_set - else - return unless node_set.kind_of? Enumerable + if node_set.respond_to? :each node_set.each { |node| yield node if defined? node.namespace } + elsif node_set.respond_to? :namespace + yield node_set end end end @@ -157,12 +156,9 @@ module REXML # Kouhei fixed this too def Functions::substring_after( string, test ) ruby_string = string(string) - ruby_index = ruby_string.index(string(test)) - if ruby_index.nil? - "" - else - ruby_string[ ruby_index+1..-1 ] - end + test_string = string(test) + return $1 if ruby_string =~ /#{test}(.*)/ + "" end # Take equal portions of Mike Stok and Sean Russell; mix @@ -339,6 +335,8 @@ module REXML end def Functions::sum( nodes ) + nodes = [nodes] unless nodes.kind_of? Array + nodes.inject(0) { |r,n| r += number(string(n)) } end def Functions::floor( number ) |