Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix a nasty bug in 1.8.x with literal sub-type initialization. Appare…

…ntly they can't call super.
  • Loading branch information...
commit 0f293b8ab9d2ba61d6f8f4bb9adb73bd992f5866 1 parent 8958b47
@gkellogg gkellogg authored
View
4 lib/rdf/model/literal/boolean.rb
@@ -14,7 +14,9 @@ class Boolean < Literal
# @param [Boolean] value
# @option options [String] :lexical (nil)
def initialize(value, options = {})
- super
+ @datatype = RDF::URI(options[:datatype] || DATATYPE)
+ @string = options[:lexical] if options.has_key?(:lexical)
+ @string ||= value if value.is_a?(String)
@object = case
when true.equal?(value) then true
when false.equal?(value) then false
View
4 lib/rdf/model/literal/date.rb
@@ -13,7 +13,9 @@ class Date < Literal
# @param [Date] value
# @option options [String] :lexical (nil)
def initialize(value, options = {})
- super
+ @datatype = RDF::URI(options[:datatype] || DATATYPE)
+ @string = options[:lexical] if options.has_key?(:lexical)
+ @string ||= value if value.is_a?(String)
@object = case
when value.is_a?(::Date) then value
when value.respond_to?(:to_date) then value.to_date # Ruby 1.9+
View
4 lib/rdf/model/literal/datetime.rb
@@ -12,7 +12,9 @@ class DateTime < Literal
# @param [DateTime] value
# @option options [String] :lexical (nil)
def initialize(value, options = {})
- super
+ @datatype = RDF::URI(options[:datatype] || DATATYPE)
+ @string = options[:lexical] if options.has_key?(:lexical)
+ @string ||= value if value.is_a?(String)
@object = case
when value.is_a?(::DateTime) then value
when value.respond_to?(:to_datetime) then value.to_datetime # Ruby 1.9+
View
4 lib/rdf/model/literal/decimal.rb
@@ -18,7 +18,9 @@ class Decimal < Numeric
# @param [BigDecimal] value
# @option options [String] :lexical (nil)
def initialize(value, options = {})
- super
+ @datatype = RDF::URI(options[:datatype] || DATATYPE)
+ @string = options[:lexical] if options.has_key?(:lexical)
+ @string ||= value if value.is_a?(String)
@object = case
when value.is_a?(BigDecimal) then value
else BigDecimal(value.to_s)
View
4 lib/rdf/model/literal/double.rb
@@ -18,7 +18,9 @@ class Double < Numeric
# @param [Float, #to_f] value
# @option options [String] :lexical (nil)
def initialize(value, options = {})
- super
+ @datatype = RDF::URI(options[:datatype] || DATATYPE)
+ @string = options[:lexical] if options.has_key?(:lexical)
+ @string ||= value if value.is_a?(String)
@object = case
when value.is_a?(::String) then case value
when 'INF' then 1/0.0
View
4 lib/rdf/model/literal/integer.rb
@@ -19,7 +19,9 @@ class Integer < Decimal
# @param [Integer, #to_i] value
# @option options [String] :lexical (nil)
def initialize(value, options = {})
- super
+ @datatype = RDF::URI(options[:datatype] || DATATYPE)
+ @string = options[:lexical] if options.has_key?(:lexical)
+ @string ||= value if value.is_a?(String)
@object = case
when value.is_a?(::String) then Integer(value) rescue nil
when value.is_a?(::Integer) then value
View
4 lib/rdf/model/literal/time.rb
@@ -17,7 +17,9 @@ class Time < Literal
# @param [Time] value
# @option options [String] :lexical (nil)
def initialize(value, options = {})
- super
+ @datatype = RDF::URI(options[:datatype] || DATATYPE)
+ @string = options[:lexical] if options.has_key?(:lexical)
+ @string ||= value if value.is_a?(String)
@object = case
when value.is_a?(::Time) then value
when value.respond_to?(:to_time) then value.to_time # Ruby 1.9+
View
4 lib/rdf/model/literal/token.rb
@@ -12,7 +12,9 @@ class Token < Literal
# @param [Symbol, #to_s] value
# @option options [String] :lexical (nil)
def initialize(value, options = {})
- super
+ @datatype = RDF::URI(options[:datatype] || DATATYPE)
+ @string = options[:lexical] if options.has_key?(:lexical)
+ @string ||= value if value.is_a?(String)
@object = value.is_a?(Symbol) ? value : value.to_s
end
Please sign in to comment.
Something went wrong with that request. Please try again.