Class: Redlander::Uri Private

Inherits:
Object
  • Object
show all
Defined in:
lib/redlander/uri.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Uri (for internal use)

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ Uri

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create Redlander::Uri

Parameters:

  • source (URI, String)

    String or URI object to wrap into Uri.

Raises:

  • (NotImplementedError)

    if cannot create a Uri from the given source.

  • (RedlandError)

    if it fails to create a Uri.



36
37
38
# File 'lib/redlander/uri.rb', line 36

def initialize(source)
  @source = source.is_a?(FFI::Pointer) ? wrap(source) : source
end

Instance Method Details

#eql?(other_uri) ⇒ Boolean Also known as: ==

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


44
45
46
# File 'lib/redlander/uri.rb', line 44

def eql?(other_uri)
  other_uri.is_a?(Uri) && (Redland.librdf_uri_equals(rdf_uri, other_uri.rdf_uri) != 0)
end

#rdf_uriObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/redlander/uri.rb', line 6

def rdf_uri
  unless instance_variable_defined?(:@rdf_uri)
    @rdf_uri = case @source
               when FFI::Pointer
                 @source
               when URI, String
                 Redland.librdf_new_uri(Redlander.rdf_world, @source.to_s)
               else
                 raise NotImplementedError, "Cannot create Uri from '#{@source.inspect}'"
               end
    raise RedlandError, "Failed to create Uri from '#{@source.inspect}'" if @rdf_uri.null?
    ObjectSpace.define_finalizer(self, self.class.send(:finalize_uri, @rdf_uri))
  end
  @rdf_uri
end

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
# File 'lib/redlander/uri.rb', line 40

def to_s
  Redland.librdf_uri_to_string(rdf_uri)
end