Module: RDF::Value
- Defined in:
- lib/rdf/nquads.rb,
lib/rdf/ntriples.rb,
lib/rdf/model/value.rb
Overview
An RDF value.
This is the basis for the RDF.rb class hierarchy. Anything that can be a term of RDF statements should directly or indirectly include this module, but it does not define classes that can be included within a Statement, for this see Term.
Instance Method Summary collapse
-
#anonymous? ⇒ Boolean
Is this value named?.
-
#canonicalize ⇒ RDF::Value
Returns a copy of this value converted into its canonical representation.
-
#canonicalize! ⇒ RDF::Value
Converts this value into its canonical representation.
-
#constant? ⇒ Boolean
Is this constant, or are all of its components constant?.
-
#graph? ⇒ Boolean
Returns ‘true` if `self` is a Graph.
-
#inspect ⇒ String
Returns a developer-friendly representation of ‘self`.
-
#inspect! ⇒ void
Outputs a developer-friendly representation of ‘self` to `stderr`.
-
#invalid? ⇒ Boolean
Is this value invalid, or is it composed of any invalid components?.
-
#iri? ⇒ Boolean
Is this an IRI?.
-
#list? ⇒ Boolean
Is this a List?.
-
#literal? ⇒ Boolean
Is this a Literal?.
-
#node? ⇒ Boolean
Is this a Node, or does it contain a node?.
-
#resource? ⇒ Boolean
Is this a Resource?.
-
#statement? ⇒ Boolean
Is this a Statement?.
-
#term? ⇒ Boolean
Is this a Term?.
-
#to_nquads ⇒ String
Returns the N-Quads representation of this value.
-
#to_ntriples ⇒ String
Returns the N-Triples representation of this value.
-
#to_rdf ⇒ RDF::Value
Returns an ‘RDF::Value` representation of `self`.
-
#to_term ⇒ RDF::Value
Returns an ‘RDF::Term` representation of `self`.
-
#type_error(message) ⇒ false
Default implementation of ‘type_error`, which returns false.
-
#uri? ⇒ Boolean
Is this an URI?.
-
#valid? ⇒ Boolean
Is this value valid, and composed only of valid components?.
-
#validate! ⇒ RDF::Value
(also: #validate)
Default validate! implementation, overridden in concrete classes.
-
#variable? ⇒ Boolean
Is this a Query::Variable, or does it contain a variable?.
Instance Method Details
#anonymous? ⇒ Boolean
Is this value named?
129 130 131 |
# File 'lib/rdf/model/value.rb', line 129 def anonymous? false end |
#canonicalize ⇒ RDF::Value
Returns a copy of this value converted into its canonical representation.
168 169 170 |
# File 'lib/rdf/model/value.rb', line 168 def canonicalize self.dup.canonicalize! end |
#canonicalize! ⇒ RDF::Value
Converts this value into its canonical representation.
Should be overridden by concrete classes.
179 180 181 |
# File 'lib/rdf/model/value.rb', line 179 def canonicalize! self end |
#constant? ⇒ Boolean
Is this constant, or are all of its components constant?
Same as ‘!variable?`
121 122 123 |
# File 'lib/rdf/model/value.rb', line 121 def constant? !(variable?) end |
#graph? ⇒ Boolean
Returns ‘true` if `self` is a Graph.
35 36 37 |
# File 'lib/rdf/model/value.rb', line 35 def graph? false end |
#inspect ⇒ String
Returns a developer-friendly representation of ‘self`.
The result will be of the format ‘#<RDF::Value::0x12345678(…)>`, where `…` is the string returned by `#to_s`.
206 207 208 |
# File 'lib/rdf/model/value.rb', line 206 def inspect sprintf("#<%s:%#0x(%s)>", self.class.name, __id__, to_s) end |
#inspect! ⇒ void
This method returns an undefined value.
Outputs a developer-friendly representation of ‘self` to `stderr`.
214 215 216 |
# File 'lib/rdf/model/value.rb', line 214 def inspect! warn(inspect) end |
#invalid? ⇒ Boolean
Is this value invalid, or is it composed of any invalid components?
147 148 149 |
# File 'lib/rdf/model/value.rb', line 147 def invalid? !valid? end |
#iri? ⇒ Boolean
93 94 95 |
# File 'lib/rdf/model/value.rb', line 93 def iri? uri? end |
#list? ⇒ Boolean
Is this a List?
51 52 53 |
# File 'lib/rdf/model/value.rb', line 51 def list? false end |
#literal? ⇒ Boolean
Is this a Literal?
75 76 77 |
# File 'lib/rdf/model/value.rb', line 75 def literal? false end |
#node? ⇒ Boolean
Is this a Node, or does it contain a node?
83 84 85 |
# File 'lib/rdf/model/value.rb', line 83 def node? false end |
#resource? ⇒ Boolean
Is this a Resource?
67 68 69 |
# File 'lib/rdf/model/value.rb', line 67 def resource? false end |
#statement? ⇒ Boolean
Is this a Statement?
43 44 45 |
# File 'lib/rdf/model/value.rb', line 43 def statement? false end |
#term? ⇒ Boolean
Is this a Term?
59 60 61 |
# File 'lib/rdf/model/value.rb', line 59 def term? false end |
#to_nquads ⇒ String
Returns the N-Quads representation of this value.
This method is only available when the ‘rdf/nquads’ serializer has been explicitly required.
166 167 168 |
# File 'lib/rdf/nquads.rb', line 166 def to_nquads RDF::NQuads.serialize(self) end |
#to_ntriples ⇒ String
Returns the N-Triples representation of this value.
This method is only available when the ‘rdf/ntriples’ serializer has been explicitly required.
98 99 100 |
# File 'lib/rdf/ntriples.rb', line 98 def to_ntriples RDF::NTriples.serialize(self) end |
#to_rdf ⇒ RDF::Value
Returns an ‘RDF::Value` representation of `self`.
187 188 189 |
# File 'lib/rdf/model/value.rb', line 187 def to_rdf self end |
#to_term ⇒ RDF::Value
Returns an ‘RDF::Term` representation of `self`.
195 196 197 |
# File 'lib/rdf/model/value.rb', line 195 def to_term raise NotImplementedError, "#{self.class}#read_triple" # override in subclasses end |
#type_error(message) ⇒ false
Default implementation of ‘type_error`, which returns false. Classes including RDF::TypeCheck will raise TypeError instead.
224 225 226 |
# File 'lib/rdf/model/value.rb', line 224 def type_error() false end |
#uri? ⇒ Boolean
Is this an URI?
101 102 103 |
# File 'lib/rdf/model/value.rb', line 101 def uri? false end |
#valid? ⇒ Boolean
Is this value valid, and composed only of valid components?
138 139 140 |
# File 'lib/rdf/model/value.rb', line 138 def valid? true end |
#validate! ⇒ RDF::Value Also known as: validate
Default validate! implementation, overridden in concrete classes
156 157 158 159 |
# File 'lib/rdf/model/value.rb', line 156 def validate! raise ArgumentError, "#{self.inspect} is not valid" if invalid? self end |
#variable? ⇒ Boolean
Is this a Query::Variable, or does it contain a variable?
110 111 112 |
# File 'lib/rdf/model/value.rb', line 110 def variable? false end |