Module: RDF::Serializers::DataTypeHelper

Included in:
HndJSONParser
Defined in:
lib/rdf/serializers/data_type_helper.rb

Instance Method Summary collapse

Instance Method Details

#xsd_to_rdf(xsd, value, **opts) ⇒ Object

rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rdf/serializers/data_type_helper.rb', line 6

def xsd_to_rdf(xsd, value, **opts) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength
  klass =
    case xsd
    when RDF::XSD[:anyURI]
      RDF::URI
    when RDF::XSD[:integer]
      RDF::Literal::Integer
    when RDF::XSD[:dateTime]
      RDF::Literal::DateTime
    when RDF::XSD[:date]
      RDF::Literal::Date
    when RDF::XSD[:boolean]
      RDF::Literal::Boolean
    when RDF::XSD[:time]
      RDF::Literal::Time
    when RDF::XSD[:long], RDF::XSD[:double]
      RDF::Literal::Double
    when RDF::XSD[:decimal]
      RDF::Literal::Decimal
    when RDF::XSD[:token]
      RDF::Literal::Token
    else
      RDF::Literal
    end

  klass.new(value, **opts)
end