Class: BNode

Inherits:
Object
  • Object
show all
Defined in:
lib/rena/bnode.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier = nil) ⇒ BNode

Returns a new instance of BNode.



3
4
5
6
7
8
9
# File 'lib/rena/bnode.rb', line 3

def initialize(identifier = nil)
  if identifier != nil && self.valid_id?(identifier) != false
    @identifier = identifier
  else
    @identifier = "bn" + self.hash.to_s
  end
end

Instance Attribute Details

#identifierObject

Returns the value of attribute identifier.



2
3
4
# File 'lib/rena/bnode.rb', line 2

def identifier
  @identifier
end

Instance Method Details

#eql?(eql) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
# File 'lib/rena/bnode.rb', line 11

def eql? (eql)
  if self.identifier == eql.identifier
    true
  else
    false
  end
end

#to_n3String

Exports the BNode in N-Triples form.

Example

b = BNode.new; b.to_n3  # => returns a string of the BNode in n3 form

Returns

Returns:

  • (String)

    The BNode in n3.

Author:

  • Tom Morris



30
31
32
# File 'lib/rena/bnode.rb', line 30

def to_n3
  "_:" + @identifier
end

#to_ntriplesString

Exports the BNode in N-Triples form.

Example

b = BNode.new; b.to_ntriples  # => returns a string of the BNode in N-Triples form

Returns

Returns:

  • (String)

    The BNode in N-Triples.

Author:

  • Tom Morris



46
47
48
# File 'lib/rena/bnode.rb', line 46

def to_ntriples
  self.to_n3
end

#to_sObject



50
51
52
# File 'lib/rena/bnode.rb', line 50

def to_s
  @identifier
end