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

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

Overview

Defined Under Namespace

Classes: BlankValue, LiteralValue, Value

Constant Summary

Constants included from RDF::Raptor::FFI

ENGINE

Instance Method Summary collapse

Methods included from RDF::Raptor::FFI

#version

Constructor Details

#initialize(ptr = nil, factory = nil) ⇒ Term

Returns a new instance of Term.

Parameters:

  • ptr (FFI::Pointer) (defaults to: nil)
  • factory (#create_node) (defaults to: nil)


69
70
71
72
# File 'lib/rdf/raptor/ffi/v2/term.rb', line 69

def initialize(ptr = nil, factory = nil)
  super(ptr)
  @factory = factory if factory
end

Instance Method Details

#release(ptr = nil)

This method returns an undefined value.

Releases libraptor memory associated with this structure.

Parameters:

  • ptr (FFI::Pointer) (defaults to: nil)


90
91
92
# File 'lib/rdf/raptor/ffi/v2/term.rb', line 90

def release(ptr = nil)
  V2.raptor_free_term(self) unless ptr.null?
end

#valueObject



74
75
76
77
78
79
80
81
82
83
# File 'lib/rdf/raptor/ffi/v2/term.rb', line 74

def value
  case self[:type]
    when RAPTOR_TERM_TYPE_BLANK
      @factory.create_node(self[:value][:blank].to_str)
    when RAPTOR_TERM_TYPE_URI
      @factory.create_uri(V2.raptor_uri_as_string(self[:value][:uri]))
    when RAPTOR_TERM_TYPE_LITERAL
      self[:value][:literal].to_rdf
  end
end