Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed RDF::Literal::Double instantiation from "INF"^^xsd:double, "-IN…

…F"^^xsd:double, and "NaN"^^xsd:double.

The following all now work as expected:

    RDF::Literal("INF", :datatype => XSD.double).to_f   #=> Infinity
    RDF::Literal("-INF", :datatype => XSD.double).to_f  #=> -Infinity
    RDF::Literal("NaN", :datatype => XSD.double).to_f   #=> NaN
  • Loading branch information...
commit ab730dbb5151649b97011020c19ca9521cb70ea7 1 parent cee47fd
@bendiken bendiken authored committed
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/rdf/model/literal/double.rb
View
9 lib/rdf/model/literal/double.rb
@@ -24,10 +24,15 @@ def initialize(value, options = {})
@string = options[:lexical] if options.has_key?(:lexical)
@string = value if !defined?(@string) && value.is_a?(String)
@object = case
- when value.is_a?(::String) then Float(value) rescue nil
+ when value.is_a?(::String) then case value
+ when 'INF' then 1/0.0
+ when '-INF' then -1/0.0
+ when 'NaN' then 0/0.0
+ else Float(value) rescue nil
+ end
when value.is_a?(::Float) then value
when value.respond_to?(:to_f) then value.to_f
- else Float(value.to_s) rescue nil
+ else Float(value.to_s) rescue nil # FIXME
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.