Class: RDF::UriNode

Inherits:
Object
  • Object
show all
Defined in:
lib/rdf/uri_node.rb

Overview

A uri node.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ UriNode

Creates a new UriNode using uri.

Raises

ArgumentError

if uri is empty

Raises:

  • (ArgumentError)


11
12
13
14
# File 'lib/rdf/uri_node.rb', line 11

def initialize(uri)
  raise ArgumentError, "uri cannot be empty" if uri.to_s.empty?
  @uri = RDF::UriNode?(uri) ? uri.uri : uri.to_s
end

Instance Attribute Details

#uriObject (readonly)

the uri of this node



5
6
7
# File 'lib/rdf/uri_node.rb', line 5

def uri
  @uri
end

Instance Method Details

#==(o) ⇒ Object Also known as: eql?

Returns true if o is a UriNode that has the same uri.



17
18
19
20
21
# File 'lib/rdf/uri_node.rb', line 17

def ==(o)
  if RDF::UriNode?(o)
    uri == o.uri
  end
end

#hashObject

Returns a hash value for this UriNode.



26
27
28
# File 'lib/rdf/uri_node.rb', line 26

def hash
  [-223574050, uri.hash].hash
end

#to_sObject

Returns the NTriples representation of this UriNode.



31
32
33
# File 'lib/rdf/uri_node.rb', line 31

def to_s
  Format::NTriples.export_node(self)
end