summaryrefslogtreecommitdiff
path: root/lib/rexml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rexml')
-rw-r--r--lib/rexml/functions.rb27
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/rexml/functions.rb b/lib/rexml/functions.rb
index 9c226d2cdf..4b46b8e678 100644
--- a/lib/rexml/functions.rb
+++ b/lib/rexml/functions.rb
@@ -315,18 +315,23 @@ module REXML
end
end
- # UNTESTED
- def Functions::boolean( object=nil )
- if object.kind_of? String
- if object =~ /\d+/u
- return object.to_f != 0
- else
- return object.size > 0
- end
- elsif object.kind_of? Array
- object = object.find{|x| x and true}
+ def Functions::boolean(object=@@context[:node])
+ case object
+ when true, false
+ object
+ when Float
+ return false if object.zero?
+ return false if object.nan?
+ true
+ when Numeric
+ not object.zero?
+ when String
+ not object.empty?
+ when Array
+ not object.empty?
+ else
+ object ? true : false
end
- return object ? true : false
end
# UNTESTED