10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/rdf_objects/data_types.rb', line 10
def self.new(value, options={})
obj = case options[:data_type]
when 'http://www.w3.org/2001/XMLSchema#dateTime' then DateTime.parse(value)
when 'http://www.w3.org/2001/XMLSchema#date' then Date.parse(value)
when 'http://www.w3.org/2001/XMLSchema#int' then value.to_i
when 'http://www.w3.org/2001/XMLSchema#string' then value.to_s
when 'http://www.w3.org/2001/XMLSchema#boolean'
if value.downcase == 'true' || value == '1'
true
else
false
end
else
value
end
obj.extend(RDFObject::Modifiers)
obj.set_data_type(options[:data_type])
obj.language = options[:language]
obj
end
|