Module: RDF::Vocabulary::Term
- Includes:
- Resource
- Defined in:
- vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb
Overview
A Vocabulary Term is a Resource that can also act as an Enumerable to generate the RDF definition of vocabulary terms as defined within the vocabulary definition.
Terms include attributes
where values a embedded resources, lists or other terms. This allows, for example, navigation of a concept heirarchy.
Instance Attribute Summary collapse
-
#allValuesFrom ⇒ Array<Term>
readonly
owl:allValuesFrom
accessor. -
#altLabel ⇒ Literal+
readonly
skos:altLabel
accessor. -
#attributes ⇒ Hash{Symbol,Resource => Term, #to_s}
readonly
Attributes of this vocabulary term, used for finding
label
andcomment
and to serialize the term back to RDF. -
#broader ⇒ Array<Term>
readonly
skos:broader
accessor. -
#cardinality ⇒ Array<Literal>
readonly
owl:cardinality
accessor. -
#comment ⇒ Literal+
readonly
rdfs:comment
accessor. -
#definition ⇒ Literal+
readonly
skos:definition
accessor. -
#domain ⇒ Array<Term>
readonly
rdfs:domain
accessor. -
#domainIncludes ⇒ Array<Term>
readonly
schema:domainIncludes
accessor. -
#editorialNote ⇒ Literal+
readonly
skos:editorialNote
accessor. -
#equivalentClass ⇒ Array<Term>
readonly
owl:equivalentClass
accessor. -
#equivalentProperty ⇒ Array<Term>
readonly
owl:equivalentProperty
accessor. -
#exactMatch ⇒ Array<Term>
readonly
skos:exactMatch
accessor. -
#hasTopConcept ⇒ Array<Term>
readonly
skos:hasTopConcept
accessor. -
#inScheme ⇒ Array<Term>
readonly
skos:inScheme
accessor. -
#intersectionOf ⇒ Array<Term>
readonly
owl:intersectionOf
accessor. -
#inverseOf ⇒ Array<Term>
readonly
owl:inverseOf
accessor. -
#isDefinedBy ⇒ Array<Term>
readonly
rdfs:isDefinedBy
accessor. -
#label ⇒ Literal
readonly
rdfs:label
accessor. -
#maxCardinality ⇒ Array<Literal>
readonly
owl:maxCardinality
accessor. -
#member ⇒ Array<Term>
readonly
skos:member
accessor. -
#minCardinality ⇒ Array<Literal>
readonly
owl:minCardinality
accessor. -
#narrower ⇒ Array<Term>
readonly
skos:narrower
accessor. -
#notation ⇒ Literal+
readonly
skos:notation
accessor. -
#note ⇒ Literal+
readonly
skos:note
accessor. -
#onProperty ⇒ Array<Term>
readonly
owl:onProperty
accessor. -
#prefLabel ⇒ Literal
readonly
skos:prefLabel
accessor. -
#range ⇒ Array<Term>
readonly
rdfs:range
accessor. -
#rangeIncludes ⇒ Array<Term>
readonly
schema:rangeIncludes
accessor. -
#related ⇒ Array<Term>
readonly
skos:related
accessor. -
#someValuesFrom ⇒ Array<Term>
readonly
owl:someValuesFrom
accessor. -
#subClassOf ⇒ Array<Term>
readonly
rdfs:subClassOf
accessor. -
#subPropertyOf ⇒ Array<Term>
readonly
rdfs:subPropertyOf
accessor. -
#type ⇒ Array<Term>
readonly
rdf:type
accessor. -
#unionOf ⇒ List<Term>, Array<Term>
readonly
owl:unionOf
accessor. -
#vocab ⇒ RDF::Vocabulary
readonly
Vocabulary of this term.
Class Method Summary collapse
-
.intern(str, *args, **options) ⇒ RDF::URI
Returns an interned
RDF::URI
instance based on the givenuri
string. - .new(*args, vocab: nil, attributes: {}, **options) ⇒ Object
Instance Method Summary collapse
-
#attribute_value(prop) ⇒ RDF::Value+
Values of an attributes as RDF::Value.
-
#class? ⇒ Boolean
Is this a class term?.
-
#datatype? ⇒ Boolean
Is this a class term?.
-
#domain_includes ⇒ RDF::URI
Accessor for
schema:domainIncludes
. -
#dup ⇒ RDF::URI
Returns a duplicate copy of
self
. -
#each_statement {|| ... } ⇒ Object
Enumerate each statement constructed from the defined vocabulary terms.
-
#enum_for(method = :each_statement, *args) ⇒ RDF::Enumerable::Enumerator
(also: #to_enum)
Return an enumerator over Statement defined for this vocabulary.
-
#inspect ⇒ String
Returns a
String
representation of the URI object's state. -
#method_missing(method, *args, &block) ⇒ Object
protected
Implement accessor to symbol attributes.
-
#other? ⇒ Boolean
Is this neither a class, property or datatype term?.
-
#properties ⇒ Hash{Symbol => Array<RDF::Value>}
Enumerate attributes with values transformed into RDF::Value instances.
-
#property? ⇒ Boolean
Is this a class term?.
-
#range_includes ⇒ RDF::URI
Accessor for
schema:rangeIncludes
. -
#respond_to?(method, include_all = false) ⇒ Boolean
Implement accessor to symbol attributes.
-
#restriction? ⇒ Boolean
Is this a Restriction term?.
-
#to_ruby(indent: "") ⇒ String
Serialize back to a Ruby source initializer.
-
#valid? ⇒ Boolean
Determine if the URI is a valid according to RFC3987.
Methods included from Resource
Methods included from Term
#<=>, #==, #aggregate?, #as_datetime, #as_number, #compatible?, #eql?, #escape, #evaluate, #ndvars, #optimize, #sameTerm?, #term?, #to_base, #to_term, #vars
Methods included from SPARQL::Algebra::Expression
cast, #constant?, #evaluate, extension, extensions, for, #invalid?, #node?, open, #optimize, #optimize!, parse, register_extension, #to_sxp_bin, #validate!, #variable?
Methods included from RDF::Value
#anonymous?, #canonicalize, #canonicalize!, #constant?, #formula?, #graph?, #inspect!, #invalid?, #iri?, #list?, #literal?, #node?, #resource?, #start_with?, #statement?, #term?, #to_ndvar, #to_nquads, #to_ntriples, #to_rdf, #to_term, #type_error, #uri?, #validate!, #variable?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (protected)
Implement accessor to symbol attributes
1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 1215 def method_missing(method, *args, &block) case method when :comment, :notation, :note, :editorialNote, :definition attribute_value(method) when :label, :altLabel, :prefLabel # Defaults to URI fragment or path tail begin attribute_value(method) rescue KeyError to_s.split(/[\/\#]/).last end when :type, :subClassOf, :subPropertyOf, :domain, :range, :isDefinedBy, :allValuesFrom, :cardinality, :equivalentClass, :equivalentProperty, :intersectionOf, :inverseOf, :maxCardinality, :minCardinality, :onProperty, :someValuesFrom, :unionOf, :domainIncludes, :rangeIncludes, :broader, :exactMatch, :hasTopConcept, :inScheme, :member, :narrower, :related # Return value as an Array, unless it is a list case value = attribute_value(method) when Array, RDF::List then value else [value].compact end else super end end |
Instance Attribute Details
#allValuesFrom ⇒ Array<Term> (readonly)
owl:allValuesFrom
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 825
|
#altLabel ⇒ Literal+ (readonly)
skos:altLabel
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 866
|
#attributes ⇒ Hash{Symbol,Resource => Term, #to_s} (readonly)
Attributes of this vocabulary term, used for finding label
and comment
and to serialize the term back to RDF.
914 915 916 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 914 def attributes @attributes end |
#broader ⇒ Array<Term> (readonly)
skos:broader
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 866
|
#cardinality ⇒ Array<Literal> (readonly)
owl:cardinality
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 825
|
#comment ⇒ Literal+ (readonly)
rdfs:comment
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 800
|
#definition ⇒ Literal+ (readonly)
skos:definition
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 866
|
#domain ⇒ Array<Term> (readonly)
rdfs:domain
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 800
|
#domainIncludes ⇒ Array<Term> (readonly)
schema:domainIncludes
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 859
|
#editorialNote ⇒ Literal+ (readonly)
skos:editorialNote
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 866
|
#equivalentClass ⇒ Array<Term> (readonly)
owl:equivalentClass
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 825
|
#equivalentProperty ⇒ Array<Term> (readonly)
owl:equivalentProperty
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 825
|
#exactMatch ⇒ Array<Term> (readonly)
skos:exactMatch
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 866
|
#hasTopConcept ⇒ Array<Term> (readonly)
skos:hasTopConcept
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 866
|
#inScheme ⇒ Array<Term> (readonly)
skos:inScheme
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 866
|
#intersectionOf ⇒ Array<Term> (readonly)
owl:intersectionOf
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 825
|
#inverseOf ⇒ Array<Term> (readonly)
owl:inverseOf
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 825
|
#isDefinedBy ⇒ Array<Term> (readonly)
rdfs:isDefinedBy
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 800
|
#label ⇒ Literal (readonly)
rdfs:label
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 800
|
#maxCardinality ⇒ Array<Literal> (readonly)
owl:maxCardinality
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 825
|
#member ⇒ Array<Term> (readonly)
skos:member
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 866
|
#minCardinality ⇒ Array<Literal> (readonly)
owl:minCardinality
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 825
|
#narrower ⇒ Array<Term> (readonly)
skos:narrower
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 866
|
#notation ⇒ Literal+ (readonly)
skos:notation
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 866
|
#note ⇒ Literal+ (readonly)
skos:note
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 866
|
#onProperty ⇒ Array<Term> (readonly)
owl:onProperty
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 825
|
#prefLabel ⇒ Literal (readonly)
skos:prefLabel
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 866
|
#range ⇒ Array<Term> (readonly)
rdfs:range
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 800
|
#rangeIncludes ⇒ Array<Term> (readonly)
schema:rangeIncludes
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 859
|
#related ⇒ Array<Term> (readonly)
skos:related
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 866
|
#someValuesFrom ⇒ Array<Term> (readonly)
owl:someValuesFrom
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 825
|
#subClassOf ⇒ Array<Term> (readonly)
rdfs:subClassOf
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 800
|
#subPropertyOf ⇒ Array<Term> (readonly)
rdfs:subPropertyOf
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 800
|
#type ⇒ Array<Term> (readonly)
rdf:type
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 800
|
#unionOf ⇒ List<Term>, Array<Term> (readonly)
owl:unionOf
accessor
|
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 825
|
#vocab ⇒ RDF::Vocabulary (readonly)
Vocabulary of this term.
910 911 912 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 910 def vocab @vocab end |
Class Method Details
.intern(str, *args, **options) ⇒ RDF::URI
Returns an interned RDF::URI
instance based on the given uri
string.
The maximum number of cached interned URI references is given by the
CACHE_SIZE
constant. This value is unlimited by default, in which
case an interned URI object will be purged only when the last strong
reference to it is garbage collected (i.e., when its finalizer runs).
Excepting special memory-limited circumstances, it should always be
safe and preferred to construct new URI references using
RDF::URI.intern
instead of RDF::URI.new
, since if an interned
object can't be returned for some reason, this method will fall back
to returning a freshly-allocated one.
967 968 969 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 967 def self.intern(str, *args, **) (URI.cache[(str = str.to_s).to_sym] ||= self.new(str, *args, **)).freeze end |
.new(uri, attributes: , **options) ⇒ Object .new(attributes: , **options) ⇒ Object
932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 932 def self.new(*args, vocab: nil, attributes: {}, **) klass = if args.first.nil? RDF::Node elsif args.first.is_a?(Hash) args.unshift(nil) RDF::Node elsif args.first.to_s.start_with?("_:") args = args[1..-1].unshift($1) RDF::Node else RDF::URI end term = klass.allocate.extend(Term) term.send(:initialize, *args) term.instance_variable_set(:@vocab, vocab) term.instance_variable_set(:@attributes, attributes) term end |
Instance Method Details
#attribute_value(prop) ⇒ RDF::Value+
Values of an attributes as RDF::Value
1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 1042 def attribute_value(prop) values = attributes[prop] values = [values].compact unless values.is_a?(Array) prop_values = values.map do |value| v = value.is_a?(Symbol) ? value.to_s : value value = (RDF::Vocabulary.(v) rescue nil) if v.is_a?(String) && v.include?(':') value = value.to_uri if value.respond_to?(:to_uri) unless value.is_a?(RDF::Value) && value.valid? # Use as most appropriate literal value = [ RDF::Literal::Date, RDF::Literal::DateTime, RDF::Literal::Integer, RDF::Literal::Decimal, RDF::Literal::Double, RDF::Literal::Boolean, RDF::Literal ].inject(nil) do |m, klass| m || begin l = klass.new(v) l if l.valid? end end end value end prop_values.length <= 1 ? prop_values.first : prop_values end |
#class? ⇒ Boolean
Is this a class term?
995 996 997 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 995 def class? Array(self.type).any? {|t| t.to_s.include?('Class')} end |
#datatype? ⇒ Boolean
Is this a class term?
1009 1010 1011 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 1009 def datatype? Array(self.type).any? {|t| t.to_s.include?('Datatype')} end |
#domain_includes ⇒ RDF::URI
Accessor for schema:domainIncludes
1164 1165 1166 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 1164 def domain_includes domainIncludes end |
#dup ⇒ RDF::URI
Returns a duplicate copy of self
.
975 976 977 978 979 980 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 975 def dup term = super.extend(Term) term.instance_variable_set(:@vocab, vocab) term.instance_variable_set(:@attributes, attributes) term end |
#each_statement {|| ... } ⇒ Object
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 1080 def each_statement attributes.keys.each do |p| values = attribute_value(p) values = [values].compact unless values.is_a?(Array) values.each do |value| begin prop = case p when :type RDF::RDFV[p] when :subClassOf, :subPropertyOf, :domain, :range, :isDefinedBy, :label, :comment RDF::RDFS[p] when :allValuesFrom, :cardinality, :equivalentClass, :equivalentProperty, :intersectionOf, :inverseOf, :maxCardinality, :minCardinality, :onProperty, :someValuesFrom, :unionOf RDF::OWL[p] when :domainIncludes, :rangeIncludes RDF::Vocabulary.find_term("http://schema.org/#{p}") when :broader, :definition, :exactMatch, :hasTopConcept, :inScheme, :member, :narrower, :related, :altLabel, :editorialNote, :notation, :note, :prefLabel RDF::Vocabulary.find_term("http://www.w3.org/2004/02/skos/core##{p}") else RDF::Vocabulary.(p) end yield RDF::Statement(self, prop, value) if prop.is_a?(RDF::URI) # Enumerate over value statements, if enumerable if value.is_a?(RDF::Enumerable) || (value.is_a?(Term) && value.node?) value.each_statement {|s| yield s} end rescue KeyError # Skip things eroneously defined in the vocabulary end end end end |
#enum_for(method = :each_statement, *args) ⇒ RDF::Enumerable::Enumerator Also known as: to_enum
Return an enumerator over Statement defined for this vocabulary.
1122 1123 1124 1125 1126 1127 1128 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 1122 def enum_for(method = :each_statement, *args) # Ensure that enumerators are, themselves, queryable this = self Enumerable::Enumerator.new do |yielder| this.send(method, *args) {|*y| yielder << (y.length > 1 ? y : y.first)} end end |
#inspect ⇒ String
Returns a String
representation of the URI object's state.
1135 1136 1137 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 1135 def inspect sprintf("#<%s:%#0x ID:%s>", Term.to_s, self.object_id, self.to_s) end |
#other? ⇒ Boolean
Is this neither a class, property or datatype term?
1023 1024 1025 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 1023 def other? Array(self.type).none? {|t| t.to_s.match?(/(Class|Property|Datatype|Restriction)/)} end |
#properties ⇒ Hash{Symbol => Array<RDF::Value>}
Enumerate attributes with values transformed into RDF::Value instances
1031 1032 1033 1034 1035 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 1031 def properties attributes.keys.inject({}) do |memo, p| memo.merge(p => attribute_value(p)) end end |
#property? ⇒ Boolean
Is this a class term?
1002 1003 1004 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 1002 def property? Array(self.type).any? {|t| t.to_s.include?('Property')} end |
#range_includes ⇒ RDF::URI
Accessor for schema:rangeIncludes
1170 1171 1172 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 1170 def range_includes rangeIncludes end |
#respond_to?(method, include_all = false) ⇒ Boolean
Implement accessor to symbol attributes
1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 1140 def respond_to?(method, include_all = false) case method when :comment, :notation, :note, :editorialNote, :definition, :label, :altLabel, :prefLabel, :type, :isDefinedBy true when :subClassOf, :subPropertyOf, :domainIncludes, :rangeIncludes, :equivalentClass, :intersectionOf, :unionOf self.class? when :domain, :range, :equivalentProperty, :inverseOf self.property? when :allValuesFrom, :cardinality, :maxCardinality, :minCardinality, :onProperty, :someValuesFrom self.restriction? when :broader, :exactMatch, :hasTopConcept, :inScheme, :member, :narrower, :related @attributes.has_key?(method) else super end end |
#restriction? ⇒ Boolean
Is this a Restriction term?
1016 1017 1018 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 1016 def restriction? Array(self.type).any? {|t| t.to_s.include?('Restriction')} end |
#to_ruby(indent: "") ⇒ String
Serialize back to a Ruby source initializer
1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 |
# File 'vendor/bundler/ruby/2.7.0/bundler/gems/rdf-0e84e3dd0307/lib/rdf/vocabulary.rb', line 1177 def to_ruby(indent: "") "term(" + (self.uri? ? self.to_s.inspect + ",\n" : "\n") + "#{indent} " + attributes.keys.sort.map do |k| values = attribute_value(k) values = [values].compact unless values.is_a?(Array) values = values.map do |value| if value.is_a?(Literal) && %w(: comment definition notation note editorialNote).include?(k.to_s) "%(#{value.to_s.gsub('(', '\(').gsub(')', '\)')}).freeze" elsif value.is_a?(RDF::URI) "#{value.pname.inspect}.freeze" elsif value.is_a?(RDF::Vocabulary::Term) value.to_ruby(indent: indent + " ") elsif value.is_a?(RDF::Term) "#{value.to_s.inspect}.freeze" elsif value.is_a?(RDF::List) list_elements = value.map do |u| if u.uri? "#{u.pname.inspect}.freeze" elsif u.respond_to?(:to_ruby) u.to_ruby(indent: indent + " ") else "#{u.to_s.inspect}.freeze" end end "list(#{list_elements.join(', ')})" else "#{value.inspect}.freeze" end end "#{k.to_s.include?(':') ? k.to_s.inspect : k}: " + (values.length == 1 ? values.first : ('[' + values.join(',') + ']')) end.join(",\n#{indent} ") + "\n#{indent})" end |