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: lib/rdf/vocab/writer.rb
+41-41Lines changed: 41 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -3,53 +3,53 @@
3
3
require'cgi'
4
4
5
5
moduleRDF
6
-
##
7
-
# Vocabulary format specification. This can be used to generate a Ruby class definition from a loaded vocabulary.
8
-
#
9
-
# Definitions can include recursive term definitions, when the value of a property is a blank-node term. They can also include list definitions, to provide a reasonable way to represent `owl:unionOf`-type relationships.
10
-
#
11
-
# @example a simple term definition
12
-
# property :comment,
13
-
# comment: %(A description of the subject resource.).freeze,
# Vocabulary format specification. This can be used to generate a Ruby class definition from a loaded vocabulary.
14
+
#
15
+
# Definitions can include recursive term definitions, when the value of a property is a blank-node term. They can also include list definitions, to provide a reasonable way to represent `owl:unionOf`-type relationships.
16
+
#
17
+
# @example a simple term definition
18
+
# property :comment,
19
+
# comment: %(A description of the subject resource.).freeze,
Copy file name to clipboardExpand all lines: lib/rdf/vocabulary.rb
+52-14Lines changed: 52 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,14 @@ module RDF
5
5
# A {Vocabulary} can also serve as a Domain Specific Language (DSL) for generating an RDF Graph definition for the vocabulary (see {RDF::Vocabulary#to_enum}).
6
6
#
7
7
# ### Defining a vocabulary using the DSL
8
-
# Vocabularies can be defined based on {RDF::Vocabulary} or {RDF::StrictVocabulary} using a simple Domain Specific Language (DSL). Terms of the vocabulary are specified using either `property` or `term` (alias), with the attributes of the term listed in a hash. See {property} for description of the hash.
8
+
# Vocabularies can be defined based on {RDF::Vocabulary} or {RDF::StrictVocabulary} using a simple Domain Specific Language (DSL).
9
+
#
10
+
# * Ontology information for the vocabulary itself can be specified using the {ontology} method.
11
+
# * Terms of the vocabulary are specified using either `property` or `term` (alias), with the attributes of the term listed in a hash. See {property} for description of the hash. Term attributes become properties of the associated {RDF::Vocabulary::Term} (see {RDF::Vocabulary::Term#attributes}).
12
+
#
13
+
# Note that, by default, the prefix associated with the vocabulary for forming and interpreting PNames is created from the class name of the vocabulary. See {\_\_prefix\_\_=} for overriding this at runtime.
14
+
#
15
+
# The simplest way to generate a DSL representation of a vocabulary is using {RDF::Vocabulary::Writer} given an {RDF::Graph} representation of the vocabulary.
# Defines a new property or class in the vocabulary.
202
+
# Defines a new property or class in the vocabulary as a {RDF::Vocabulary::Term}.
180
203
#
181
204
# @example A simple term definition
182
205
# property :domain,
@@ -1109,7 +1132,7 @@ def other?
1109
1132
1110
1133
##
1111
1134
# Enumerate attributes with values transformed into {RDF::Value} instances
1112
-
# Uses an empty hash with a default_proc which looks up values in attributes.
1135
+
# Uses an empty hash with a default_proc which looks up values in attributes. The prevents specific attributes from being evaluated until acessed.
1113
1136
#
1114
1137
# Properties are indexed by symbol. Symbols directly interpreted by a term are the accessors defined for the {RDF::Vocabulary::Term} class, also in {Term::ATTR_URIs}. Other keys are interpreted as absolute URIs or PNames for properties defined on this term.
1115
1138
#
@@ -1131,7 +1154,20 @@ def properties
1131
1154
end
1132
1155
1133
1156
##
1134
-
# Values of an attributes as {RDF::Value}
1157
+
# Values of an attributes as {RDF::Value}.
1158
+
#
1159
+
# Attribute values are returned as either an {RDF::Value} or {Array<RDf::Value} if there is more than one value.
1160
+
#
1161
+
# Attribute values which are not already a {RDF::Value} (including strings and symbols) are converted by a heuristic loookup as follows:
1162
+
#
1163
+
# * An {RDF::URI} if it can be turned into a valid IRI using {RDF::Vocabulary.expand_pname}. This includes IRIs already in non-relative form.
1164
+
# * {RDF::Literal::Date} if valud,
1165
+
# * {RDF::Literal::DateTime} if valid,
1166
+
# * {RDF::Literal::Integer} if valid,
1167
+
# * {RDF::Literal::Decimal} if valid,
1168
+
# * {RDF::Literal::Double} if valid,
1169
+
# * {RDF::Literal::Boolean} if valid
1170
+
# * Otherwise, {RDF::Literal} where type may be inferred by the class of the value.
1135
1171
#
1136
1172
# @param [Symbol] prop
1137
1173
# @return [RDF::Value, Array<RDF::Value>]
@@ -1246,7 +1282,9 @@ def range_includes
1246
1282
rangeIncludes
1247
1283
end
1248
1284
1249
-
# Serialize back to a Ruby source initializer
1285
+
##
1286
+
# Serialize back to a Ruby source initializer. This is used primarily by {RDF::Vocabulary::Writer}.
0 commit comments