Class: RDF::TypedLiteralNode
- Inherits:
-
Object
- Object
- RDF::TypedLiteralNode
- Defined in:
- lib/rdf/typed_literal_node.rb
Overview
A typed literal node.
Instance Attribute Summary collapse
-
#datatype_uri ⇒ Object
readonly
the datatype uri of this TypedLiteralNode.
-
#lexical_form ⇒ Object
readonly
the lexical form of this TypedLiteralNode.
Instance Method Summary collapse
-
#==(o) ⇒ Object
(also: #eql?)
Returns true if
o
is a TypedLiteralNode with the samelexical_form
anddatatype_uri
. -
#hash ⇒ Object
Returns a hash value for this TypedLiteralNode.
-
#initialize(lexical_form, datatype_uri) ⇒ TypedLiteralNode
constructor
Creates a new TypedLiteralNode using the specified
lexical_form
anddatatype_uri
. -
#to_s ⇒ Object
Returns the NTriples representation of this TypedLiteralNode.
Constructor Details
#initialize(lexical_form, datatype_uri) ⇒ TypedLiteralNode
Creates a new TypedLiteralNode using the specified lexical_form
and datatype_uri
. Raises an ArgumentError if datatype_uri
is empty. If datatype_uri
is a UriNode, it will automatically convert it to just the URI string.
12 13 14 15 16 17 |
# File 'lib/rdf/typed_literal_node.rb', line 12 def initialize(lexical_form, datatype_uri) @lexical_form = lexical_form.to_s @datatype_uri = RDF::UriNode?(datatype_uri) ? datatype_uri.uri : datatype_uri.to_s raise ArgumentError, "datatype_uri cannot be empty" if @datatype_uri.empty? end |
Instance Attribute Details
#datatype_uri ⇒ Object (readonly)
the datatype uri of this TypedLiteralNode.
7 8 9 |
# File 'lib/rdf/typed_literal_node.rb', line 7 def datatype_uri @datatype_uri end |
#lexical_form ⇒ Object (readonly)
the lexical form of this TypedLiteralNode.
5 6 7 |
# File 'lib/rdf/typed_literal_node.rb', line 5 def lexical_form @lexical_form end |
Instance Method Details
#==(o) ⇒ Object Also known as: eql?
Returns true if o
is a TypedLiteralNode with the same lexical_form
and datatype_uri
.
20 21 22 23 24 25 |
# File 'lib/rdf/typed_literal_node.rb', line 20 def ==(o) if RDF::TypedLiteralNode?(o) lexical_form == o.lexical_form && datatype_uri == o.datatype_uri end end |
#hash ⇒ Object
Returns a hash value for this TypedLiteralNode.
30 31 32 |
# File 'lib/rdf/typed_literal_node.rb', line 30 def hash [375836169, lexical_form.hash, datatype_uri.hash].hash end |
#to_s ⇒ Object
Returns the NTriples representation of this TypedLiteralNode.
35 36 37 |
# File 'lib/rdf/typed_literal_node.rb', line 35 def to_s Format::NTriples.export_node(self) end |