Class: Reddy::BNode
- Inherits:
-
Object
- Object
- Reddy::BNode
- Defined in:
- lib/reddy/bnode.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
Returns the value of attribute identifier.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(identifier = nil) ⇒ BNode
constructor
A new instance of BNode.
-
#to_n3 ⇒ String
Exports the BNode in N-Triples form.
-
#to_ntriples ⇒ String
Exports the BNode in N-Triples form.
-
#to_s ⇒ String
Returns the identifier as a string.
Constructor Details
#initialize(identifier = nil) ⇒ BNode
Returns a new instance of BNode.
4 5 6 7 8 9 10 11 |
# File 'lib/reddy/bnode.rb', line 4 def initialize(identifier = nil) if identifier != nil && self.valid_id?(identifier) != false @identifier = identifier else @identifier = "bn" + self.hash.to_i.abs.to_s # perhaps this needs to be slightly cleverer - check whether it's negative, and if it is, append an extra bit on the end aaaaaas distinction. TODO end end |
Instance Attribute Details
#identifier ⇒ Object
Returns the value of attribute identifier.
3 4 5 |
# File 'lib/reddy/bnode.rb', line 3 def identifier @identifier end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
13 14 15 |
# File 'lib/reddy/bnode.rb', line 13 def eql? (other) other.is_a?(self.class) && other.identifier == self.identifier end |
#to_n3 ⇒ String
30 31 32 |
# File 'lib/reddy/bnode.rb', line 30 def to_n3 "_:" + @identifier end |
#to_ntriples ⇒ String
46 47 48 |
# File 'lib/reddy/bnode.rb', line 46 def to_ntriples self.to_n3 end |
#to_s ⇒ String
Returns the identifier as a string.
Returns
57 58 59 |
# File 'lib/reddy/bnode.rb', line 57 def to_s @identifier end |