Class: RDF::Raptor::FFI::V2::URI
- Inherits:
-
FFI::ManagedStruct
- Object
- FFI::ManagedStruct
- RDF::Raptor::FFI::V2::URI
- Includes:
- RDF::Raptor::FFI, RDF::Resource
- Defined in:
- lib/rdf/raptor/ffi/v2/uri.rb
Overview
Raptor has a raptor_uri
class which must be used for manipulating and passing URI references. The default internal implementation uses char*
strings for URIs, manipulating them and constructing them.
Constant Summary
Constants included from RDF::Raptor::FFI
Class Method Summary collapse
-
.release(ptr)
Releases
libraptor
memory associated with this structure.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #===)
true
orfalse
. -
#clone ⇒ URI
A copy of
self
. -
#dup ⇒ URI
A copy of
self
. -
#eql?(other) ⇒ Boolean
true
orfalse
. - #hash ⇒ Fixnum
-
#initialize(ptr_or_name) ⇒ URI
constructor
A new instance of URI.
- #length ⇒ Integer (also: #size)
- #to_rdf ⇒ RDF::URI (also: #to_uri)
-
#to_str ⇒ String
(also: #to_s)
The URI string.
-
#uri? ⇒ Boolean
true
.
Methods included from RDF::Raptor::FFI
Constructor Details
#initialize(ptr) ⇒ URI #initialize(name) ⇒ URI
Returns a new instance of URI.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rdf/raptor/ffi/v2/uri.rb', line 20 def initialize(ptr_or_name) ptr = case ptr_or_name when FFI::Pointer then ptr_or_name when RDF::URI then V2.raptor_new_uri(V2.world, ptr_or_name.to_s) when String then V2.raptor_new_uri(V2.world, ptr_or_name) else nil end raise ArgumentError, "invalid argument: #{ptr_or_name.inspect}" if ptr.nil? || ptr.null? super(ptr) end |
Class Method Details
.release(ptr)
This method returns an undefined value.
Releases libraptor
memory associated with this structure.
36 37 38 |
# File 'lib/rdf/raptor/ffi/v2/uri.rb', line 36 def self.release(ptr) V2.raptor_free_uri(ptr) end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: ===
Returns true
or false
.
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rdf/raptor/ffi/v2/uri.rb', line 72 def ==(other) return true if self.equal?(other) case other when self.class !(V2.raptor_uri_equals(self, other).zero?) when RDF::URI, String to_str == other.to_str else false end end |
#clone ⇒ URI
Returns a copy of self
.
56 57 58 59 60 61 |
# File 'lib/rdf/raptor/ffi/v2/uri.rb', line 56 def clone copy = self.class.new(V2.raptor_uri_copy(self)) copy.taint if tainted? copy.freeze if frozen? copy end |
#dup ⇒ URI
Returns a copy of self
.
48 49 50 51 52 |
# File 'lib/rdf/raptor/ffi/v2/uri.rb', line 48 def dup copy = self.class.new(V2.raptor_uri_copy(self)) copy.taint if tainted? copy end |
#eql?(other) ⇒ Boolean
Returns true
or false
.
86 87 88 89 |
# File 'lib/rdf/raptor/ffi/v2/uri.rb', line 86 def eql?(other) return true if self.equal?(other) other.is_a?(self.class) && !(V2.raptor_uri_equals(self, other).zero?) end |
#hash ⇒ Fixnum
93 94 95 |
# File 'lib/rdf/raptor/ffi/v2/uri.rb', line 93 def hash to_str.hash end |
#length ⇒ Integer Also known as: size
65 66 67 |
# File 'lib/rdf/raptor/ffi/v2/uri.rb', line 65 def length LibC.strlen(self) end |
#to_rdf ⇒ RDF::URI Also known as: to_uri
106 107 108 |
# File 'lib/rdf/raptor/ffi/v2/uri.rb', line 106 def to_rdf RDF::URI.intern(to_str) end |
#to_str ⇒ String Also known as: to_s
Returns the URI string.
99 100 101 |
# File 'lib/rdf/raptor/ffi/v2/uri.rb', line 99 def to_str V2.raptor_uri_as_string(self) end |
#uri? ⇒ Boolean
Returns true
.
42 43 44 |
# File 'lib/rdf/raptor/ffi/v2/uri.rb', line 42 def uri? true end |