Module: RDF::JSON::Extensions::Literal

Defined in:
vendor/bundler/ruby/2.4.0/bundler/gems/rdf-json-3f36e90af14f/lib/rdf/json/extensions.rb

Overview

RDF/JSON extensions for RDF::Literal.

Instance Method Summary collapse

Instance Method Details

#to_rdf_jsonHash

Returns the RDF/JSON representation of this literal.

Returns:



73
74
75
76
77
78
79
80
81
82
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-json-3f36e90af14f/lib/rdf/json/extensions.rb', line 73

def to_rdf_json
  case
    when has_datatype?
      {:type => :literal, :value => value.to_s, :datatype => datatype.to_s}
    when has_language?
      {:type => :literal, :value => value.to_s, :lang => language.to_s}
    else
      {:type => :literal, :value => value.to_s}
  end
end