class RDF::Literal

Public Instance Methods

to_sxp() click to toggle source

Returns the SXP representation of a Literal.

@return [String]

# File lib/sxp/writer.rb, line 176
def to_sxp
  case datatype
  when RDF::XSD.boolean, RDF::XSD.integer, RDF::XSD.double, RDF::XSD.decimal, RDF::XSD.time
    # Retain stated lexical form if possible
    valid? ? to_s : object.to_sxp
  else
    text = value.dump
    text << "@#{language}" if self.has_language?
    text << "^^#{datatype.to_sxp}" if self.has_datatype?
    text
  end
end