Class: RDF::PlainLiteralNode
- Inherits:
-
Object
- Object
- RDF::PlainLiteralNode
- Defined in:
- lib/rdf/plain_literal_node.rb
Overview
A plain literal node.
Instance Attribute Summary collapse
-
#language_tag ⇒ Object
readonly
the language tag (if any) of this LiteralNode.
-
#lexical_form ⇒ Object
readonly
the lexical form of this LiteralNode.
Instance Method Summary collapse
-
#==(o) ⇒ Object
(also: #eql?)
Returns true if
o
is a PlainLiteralNode with the samelexical_form
andlanguage_tag
(if any). -
#hash ⇒ Object
Returns a hash value for this PlainLiteralNode.
-
#initialize(lexical_form, language_tag = nil) ⇒ PlainLiteralNode
constructor
Creates a new literal node with the specified
lexical_form
andlanguage_tag
. -
#to_s ⇒ Object
Returns the NTriples representation of this PlainLiteralNode.
Constructor Details
#initialize(lexical_form, language_tag = nil) ⇒ PlainLiteralNode
Creates a new literal node with the specified lexical_form
and language_tag
.
10 11 12 13 |
# File 'lib/rdf/plain_literal_node.rb', line 10 def initialize(lexical_form, language_tag = nil) @lexical_form = lexical_form @language_tag = language_tag end |
Instance Attribute Details
#language_tag ⇒ Object (readonly)
the language tag (if any) of this LiteralNode.
7 8 9 |
# File 'lib/rdf/plain_literal_node.rb', line 7 def language_tag @language_tag end |
#lexical_form ⇒ Object (readonly)
the lexical form of this LiteralNode.
5 6 7 |
# File 'lib/rdf/plain_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 PlainLiteralNode with the same lexical_form
and language_tag
(if any).
17 18 19 20 21 22 |
# File 'lib/rdf/plain_literal_node.rb', line 17 def ==(o) if RDF::PlainLiteralNode?(o) lexical_form == o.lexical_form && language_tag.to_s.downcase == o.language_tag.to_s.downcase end end |
#hash ⇒ Object
Returns a hash value for this PlainLiteralNode.
27 28 29 |
# File 'lib/rdf/plain_literal_node.rb', line 27 def hash [-1025818701, lexical_form.hash, language_tag.to_s.downcase.hash].hash end |
#to_s ⇒ Object
Returns the NTriples representation of this PlainLiteralNode.
32 33 34 |
# File 'lib/rdf/plain_literal_node.rb', line 32 def to_s Format::NTriples.export_node(self) end |