class RDF::Raptor::FFI::V2::Term

@see librdf.org/raptor/api-1.4/raptor-section-triples.html

Public Class Methods

new(ptr = nil, factory = nil) click to toggle source

@param [FFI::Pointer] ptr @param [#create_node] factory

Calls superclass method
# File lib/rdf/raptor/ffi/v2/term.rb, line 69
def initialize(ptr = nil, factory = nil)
  super(ptr)
  @factory = factory if factory
end

Public Instance Methods

release(ptr = nil) click to toggle source

Releases ‘libraptor` memory associated with this structure.

@param [FFI::Pointer] ptr @return [void]

# File lib/rdf/raptor/ffi/v2/term.rb, line 90
def release(ptr = nil)
  V2.raptor_free_term(self) unless ptr.null?
end
value() click to toggle source
# 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