Class: RDF::Raptor::FFI::V2::Term::LiteralValue

Inherits:
FFI::Struct
  • Object
show all
Includes:
RDF::Raptor::FFI
Defined in:
lib/rdf/raptor/ffi/v2/term.rb

Constant Summary

Constants included from RDF::Raptor::FFI

ENGINE

Instance Method Summary collapse

Methods included from RDF::Raptor::FFI

#version

Instance Method Details

#datatypeObject



26
27
28
29
30
# File 'lib/rdf/raptor/ffi/v2/term.rb', line 26

def datatype
  if self[:datatype] && !self[:datatype].null?
    RDF::URI.intern(V2.raptor_uri_to_string(self[:datatype]))
  end
end

#languageObject



20
21
22
23
24
# File 'lib/rdf/raptor/ffi/v2/term.rb', line 20

def language
  unless self[:language].nil? or self[:language].empty?
    self[:language]
  end
end

#to_rdfObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rdf/raptor/ffi/v2/term.rb', line 32

def to_rdf
  str = self.to_str
  case
    when language = self.language
      RDF::Literal.new(str, language: language)
    when datatype = self.datatype
      RDF::Literal.new(str, datatype: datatype)
    else
      RDF::Literal.new(str)
  end
end

#to_strObject



16
17
18
# File 'lib/rdf/raptor/ffi/v2/term.rb', line 16

def to_str
  self[:string].unpack('U*').pack('U*')
end