You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-2Lines changed: 9 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,6 +102,9 @@ the 1.1 release of RDF.rb:
102
102
103
103
Notably, {RDF::Queryable#query} and {RDF::Query#execute} are now completely symmetric; this allows an implementation of {RDF::Queryable} to optimize queries using implementation-specific logic, allowing for substantial performance improvements when executing BGP queries.
104
104
105
+
## Differences between RDF 1.1 and RDF 1.2
106
+
* {RDF::Literal} has an optional `direction` property for directional language-tagged strings.
107
+
105
108
## Tutorials
106
109
107
110
*[Getting data from the Semantic Web using Ruby and RDF.rb](https://semanticweb.org/wiki/Getting_data_from_the_Semantic_Web_%28Ruby%29)
@@ -400,6 +403,7 @@ from BNode identity (i.e., they each entail the other)
400
403
401
404
*[Ruby](https://ruby-lang.org/) (>= 2.6)
402
405
*[LinkHeader][] (>= 0.0.8)
406
+
*[bcp47_spec][] ( ~> 0.2)
403
407
* Soft dependency on [RestClient][] (>= 2.1)
404
408
405
409
## Installation
@@ -481,8 +485,10 @@ This is free and unencumbered public domain software. For more information,
481
485
see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
Copy file name to clipboardExpand all lines: lib/rdf/model/literal.rb
+83-31Lines changed: 83 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,7 @@
1
1
# -*- encoding: utf-8 -*-
2
+
3
+
require'bcp47_spec'
4
+
2
5
moduleRDF
3
6
##
4
7
# An RDF literal.
@@ -9,7 +12,9 @@ module RDF
9
12
#
10
13
# Specific typed literals may have behavior different from the default implementation. See the following defined sub-classes for specific documentation. Additional sub-classes may be defined, and will interoperate by defining `DATATYPE` and `GRAMMAR` constants, in addition other required overrides of RDF::Literal behavior.
11
14
#
12
-
# In RDF 1.1, all literals are typed, including plain literals and language tagged literals. Internally, plain literals are given the `xsd:string` datatype and language tagged literals are given the `rdf:langString` datatype. Creating a plain literal, without a datatype or language, will automatically provide the `xsd:string` datatype; similar for language tagged literals. Note that most serialization formats will remove this datatype. Code which depends on a literal having the `xsd:string` datatype being different from a plain literal (formally, without a datatype) may break. However note that the `#has\_datatype?` will continue to return `false` for plain or language-tagged literals.
15
+
# In RDF 1.1, all literals are typed, including plain literals and language-tagged strings. Internally, plain literals are given the `xsd:string` datatype and language-tagged strings are given the `rdf:langString` datatype. Creating a plain literal, without a datatype or language, will automatically provide the `xsd:string` datatype; similar for language-tagged strings. Note that most serialization formats will remove this datatype. Code which depends on a literal having the `xsd:string` datatype being different from a plain literal (formally, without a datatype) may break. However note that the `#has\_datatype?` will continue to return `false` for plain or language-tagged strings.
16
+
#
17
+
# RDF 1.2 adds **directional language-tagged strings** which are effectively a subclass of **language-tagged strings** contining an additional **direction** component with value either **ltr** or **rtl** for Left-to-Right or Right-to-Left. This determines the general direction of a string when presented in n a user agent, where it might be in conflict with the inherent direction of the leading Unicode code points. Directional language-tagged strings are given the `rdf:langString` datatype.
13
18
#
14
19
# * {RDF::Literal::Boolean}
15
20
# * {RDF::Literal::Date}
@@ -23,16 +28,23 @@ module RDF
23
28
# value = RDF::Literal.new("Hello, world!")
24
29
# value.plain? #=> true`
25
30
#
26
-
# @example Creating a language-tagged literal (1)
31
+
# @example Creating a language-tagged string (1)
27
32
# value = RDF::Literal.new("Hello!", language: :en)
28
33
# value.language? #=> true
29
34
# value.language #=> :en
30
35
#
31
-
# @example Creating a language-tagged literal (2)
36
+
# @example Creating a language-tagged string (2)
32
37
# RDF::Literal.new("Wazup?", language: :"en-US")
33
38
# RDF::Literal.new("Hej!", language: :sv)
34
39
# RDF::Literal.new("¡Hola!", language: :es)
35
40
#
41
+
# @example Creating a directional language-tagged string
42
+
# value = RDF::Literal.new("Hello!", language: :en, direction: :ltr)
43
+
# value.language? #=> true
44
+
# value.language #=> :en
45
+
# value.direction? #=> true
46
+
# value.direction #=> :ltr
47
+
#
36
48
# @example Creating an explicitly datatyped literal
37
49
# value = RDF::Literal.new("2009-12-31", datatype: RDF::XSD.date)
0 commit comments