class RDF::Raptor::FFI::V2::Statement
Attributes
@return [RDF::Resource]
@return [Object]
Public Class Methods
@param [FFI::Pointer] ptr @param [#create_node] factory
# File lib/rdf/raptor/ffi/v2/statement.rb, line 16 def initialize(ptr = nil, factory = nil) super(ptr) @factory = factory if factory end
Public Instance Methods
Releases ‘libraptor` memory associated with this structure.
@return [void]
# File lib/rdf/raptor/ffi/v2/statement.rb, line 137 def free V2.raptor_free_statement(self) @subject = @predicate = @object = nil # Allow GC to start end
@return [RDF::Term]
# File lib/rdf/raptor/ffi/v2/statement.rb, line 79 def object @object ||= V2::Term.new(self[:object], @factory).value end
Sets the object term from an ‘RDF::Term`.
The value must be one of ‘RDF::Resource` or `RDF::Literal`.
@param [RDF::Term] value @return [void]
# File lib/rdf/raptor/ffi/v2/statement.rb, line 90 def object=(value) @object = nil case value when RDF::Node self[:object] = V2.raptor_new_term_from_blank(V2.world, value.id.to_s) when RDF::URI self[:object] = V2.raptor_new_term_from_uri_string(V2.world, value.to_s) when RDF::Literal self[:object] = V2.raptor_new_term_from_literal(V2.world, value.to_s, value.datatype? ? V2.raptor_new_uri(V2.world, value.datatype.to_s) : nil, value.language? ? value.language.to_s : nil) else raise ArgumentError, "object term must be an RDF::Node, RDF::URI, or RDF::Literal" end @object = value end
@return [RDF::URI]
# File lib/rdf/raptor/ffi/v2/statement.rb, line 61 def predicate @predicate ||= V2::Term.new(self[:predicate], @factory).value end
Sets the predicate term from an ‘RDF::URI`.
@param [RDF::URI] uri @return [void]
# File lib/rdf/raptor/ffi/v2/statement.rb, line 70 def predicate=(uri) @predicate = nil raise ArgumentError, "predicate term must be an RDF::URI" unless uri.is_a?(RDF::URI) self[:predicate] = V2.raptor_new_term_from_uri_string(V2.world, uri.to_s) @predicate = uri end
Releases ‘libraptor` memory associated with this structure.
@return [void]
# File lib/rdf/raptor/ffi/v2/statement.rb, line 25 def release V2.raptor_free_statement(ptr) unless ptr.null? end
@return [void]
# File lib/rdf/raptor/ffi/v2/statement.rb, line 129 def reset! @subject = @predicate = @object = @graph_name = nil end
@return [RDF::Resource]
# File lib/rdf/raptor/ffi/v2/statement.rb, line 37 def subject @subject ||= V2::Term.new(self[:subject], @factory).value end
Sets the subject term from an ‘RDF::Resource`.
@param [RDF::Resource] resource @return [void]
# File lib/rdf/raptor/ffi/v2/statement.rb, line 46 def subject=(resource) @subject = nil case resource when RDF::Node self[:subject] = V2.raptor_new_term_from_blank(V2.world, resource.id.to_s) when RDF::URI self[:subject] = V2.raptor_new_term_from_uri_string(V2.world, resource.to_s) else raise ArgumentError, "subject term must be an RDF::Node or RDF::URI" end @subject = resource end
@return [Array(RDF::Resource, RDF::URI, RDF::Term, nil)] @see RDF::Statement#to_quad
# File lib/rdf/raptor/ffi/v2/statement.rb, line 117 def to_quad [subject, predicate, object, graph_name] end
@return [RDF::Statement]
# File lib/rdf/raptor/ffi/v2/statement.rb, line 123 def to_rdf RDF::Statement.new(subject, predicate, object, graph_name: graph_name) end
@return [Array(RDF::Resource, RDF::URI, RDF::Term)] @see RDF::Statement#to_triple
# File lib/rdf/raptor/ffi/v2/statement.rb, line 110 def to_triple [subject, predicate, object] end