Class: RDF::PlainLiteralNode

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

Overview

A plain literal node.

Instance Attribute Summary collapse

Instance Method Summary collapse

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_tagObject (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_formObject (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

#hashObject

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_sObject

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