Class: RDF::RDFa::Reader::EvaluationContext
- Inherits:
-
Object
- Object
- RDF::RDFa::Reader::EvaluationContext
- Defined in:
- lib/rdf/rdfa/reader.rb
Overview
The Recursive Baggage
Instance Attribute Summary collapse
-
#base ⇒ RDF::URI
The base.
-
#default_vocabulary ⇒ RDF::URI
The default vocabulary.
-
#incomplete_triples ⇒ Array<Array<RDF::URI, RDF::Resource>>
A list of incomplete triples.
-
#language ⇒ Symbol
The language.
-
#list_mapping ⇒ Hash{RDF:URI: Array<RDF::Resource>}
lists.
-
#namespaces ⇒ Hash{String => Namespace}
A list of current, in-scope Namespaces.
-
#parent_object ⇒ RDF::URI
The parent object.
-
#parent_subject ⇒ RDF::URI
The parent subject.
-
#term_mappings ⇒ Hash{Symbol => RDF::URI}
The term mappings, a list of terms and their associated URIs.
-
#uri_mappings ⇒ Hash{Symbol => String}
A list of current, in-scope URI mappings.
Instance Method Summary collapse
-
#initialize(base, host_defaults) ⇒ EvaluationContext
constructor
A new instance of EvaluationContext.
-
#initialize_copy(from) ⇒ Object
Copy this Evaluation Context.
- #inspect ⇒ Object
Constructor Details
#initialize(base, host_defaults) ⇒ EvaluationContext
Returns a new instance of EvaluationContext.
210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/rdf/rdfa/reader.rb', line 210 def initialize(base, host_defaults) # Initialize the evaluation context, [5.1] @base = base @parent_subject = @base @parent_object = nil @namespaces = {} @incomplete_triples = [] @language = nil @uri_mappings = host_defaults.fetch(:uri_mappings, {}) @term_mappings = host_defaults.fetch(:term_mappings, {}) @default_vocabulary = host_defaults.fetch(:vocabulary, nil) end |
Instance Attribute Details
#base ⇒ RDF::URI
The base.
This will usually be the URL of the document being processed, but it could be some other URL, set by some other mechanism, such as the (X)HTML base element. The important thing is that it establishes a URL against which relative paths can be resolved.
116 117 118 |
# File 'lib/rdf/rdfa/reader.rb', line 116 def base @base end |
#default_vocabulary ⇒ RDF::URI
The default vocabulary
A value to use as the prefix URI when a term is used. This specification does not define an initial setting for the default vocabulary. Host Languages may define an initial setting.
196 197 198 |
# File 'lib/rdf/rdfa/reader.rb', line 196 def default_vocabulary @default_vocabulary end |
#incomplete_triples ⇒ Array<Array<RDF::URI, RDF::Resource>>
A list of incomplete triples.
A triple can be incomplete when no object resource is provided alongside a predicate that requires a resource (i.e., @rel or @rev). The triples can be completed when a resource becomes available, which will be when the next subject is specified (part of the process called chaining).
167 168 169 |
# File 'lib/rdf/rdfa/reader.rb', line 167 def incomplete_triples @incomplete_triples end |
#language ⇒ Symbol
The language. Note that there is no default language.
174 175 176 |
# File 'lib/rdf/rdfa/reader.rb', line 174 def language @language end |
#list_mapping ⇒ Hash{RDF:URI: Array<RDF::Resource>}
lists
A hash associating lists with properties.
204 205 206 |
# File 'lib/rdf/rdfa/reader.rb', line 204 def list_mapping @list_mapping end |
#namespaces ⇒ Hash{String => Namespace}
A list of current, in-scope Namespaces. This is the subset of uri_mappings which are defined using xmlns.
155 156 157 |
# File 'lib/rdf/rdfa/reader.rb', line 155 def namespaces @namespaces end |
#parent_object ⇒ RDF::URI
The parent object.
In some situations the object of a statement becomes the subject of any nested statements, and this property is used to convey this value. Note that this value may be a bnode, since in some situations a number of nested statements are grouped together on one bnode. This means that the bnode must be set in the containing statement and passed down, and this property is used to convey this value.
140 141 142 |
# File 'lib/rdf/rdfa/reader.rb', line 140 def parent_object @parent_object end |
#parent_subject ⇒ RDF::URI
The parent subject.
The initial value will be the same as the initial value of base, but it will usually change during the course of processing.
126 127 128 |
# File 'lib/rdf/rdfa/reader.rb', line 126 def parent_subject @parent_subject end |
#term_mappings ⇒ Hash{Symbol => RDF::URI}
The term mappings, a list of terms and their associated URIs.
This specification does not define an initial list. Host Languages may define an initial list. If a Host Language provides an initial list, it should do so via an RDFa Context document.
185 186 187 |
# File 'lib/rdf/rdfa/reader.rb', line 185 def term_mappings @term_mappings end |
#uri_mappings ⇒ Hash{Symbol => String}
A list of current, in-scope URI mappings.
147 148 149 |
# File 'lib/rdf/rdfa/reader.rb', line 147 def uri_mappings @uri_mappings end |
Instance Method Details
#initialize_copy(from) ⇒ Object
Copy this Evaluation Context
226 227 228 229 230 231 232 |
# File 'lib/rdf/rdfa/reader.rb', line 226 def initialize_copy(from) # clone the evaluation context correctly @uri_mappings = from.uri_mappings.clone @incomplete_triples = from.incomplete_triples.clone @namespaces = from.namespaces.clone @list_mapping = from.list_mapping # Don't clone end |
#inspect ⇒ Object
234 235 236 237 238 239 240 241 242 243 |
# File 'lib/rdf/rdfa/reader.rb', line 234 def inspect v = ['base', 'parent_subject', 'parent_object', 'language', 'default_vocabulary'].map do |a| "#{a}=#{o = self.send(a); o.respond_to?(:to_ntriples) ? o.to_ntriples : o.inspect}" end v << "uri_mappings[#{uri_mappings.keys.length}]" v << "incomplete_triples[#{incomplete_triples.length}]" v << "term_mappings[#{term_mappings.keys.length}]" v << "lists[#{list_mapping.keys.length}]" if list_mapping v.join(", ") end |