Class: Array
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/json-ld-f1de87658826/lib/json/ld/extensions.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/sxp.rb-7a771a32c5fe/lib/sxp/extensions.rb,
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/extensions.rb
Overview
REXML C14N
Direct Known Subclasses
Instance Method Summary collapse
- #aggregate? ⇒ Boolean
-
#bind(solution) ⇒ self
Binds the pattern to a solution, making it no longer variable if all variables are resolved to bound variables.
-
#c14nxl(options = {}) ⇒ Object
Canonicalize the NodeSet.
- #constant? ⇒ Boolean
-
#deep_dup ⇒ Object
Deep duplicate.
- #evaluatable? ⇒ Boolean
- #executable? ⇒ Boolean
-
#execute(queryable, **options) ⇒ Object
If
#execute
is invoked, it implies that a non-implemented Algebra operator is being invoked. -
#ndvars ⇒ Array<RDF::Query::Variable>
Return the non-destinguished variables contained within this Array.
-
#node? ⇒ Boolean
Does this contain any nodes?.
-
#opt_sort(ordered: false) ⇒ Array
Optionally order items.
-
#optimize(**options) ⇒ Array
Return an optimized version of this array.
-
#replace_aggregate! {|agg| ... } ⇒ SPARQL::Algebra::Evaluatable, RDF::Query::Variable
Recursively re-map operators to replace aggregates with temporary variables returned from the block.
-
#replace_vars! {|var| ... } ⇒ SPARQL::Algebra::Evaluatable
Replace operators which are variables with the result of the block descending into operators which are also evaluatable.
-
#to_s_with_c14nxl ⇒ Object
(also: #to_s)
Serialize a canonicalized Node or NodeSet to XML.
-
#to_sparql(delimiter: " ", **options) ⇒ String
Returns a partial SPARQL grammar for this array.
-
#to_sxp ⇒ String
Returns the SXP representation of this object.
-
#to_sxp_bin ⇒ String
Returns the SXP representation of this object, defaults to
self
. -
#valid? ⇒ Boolean
Is this value composed only of valid components?.
-
#validate! ⇒ Array
Validate all components.
-
#variable? ⇒ Boolean
Returns
true
if any of the operands are variables,false
otherwise. -
#variables ⇒ Hash{Symbol => RDF::Query::Variable}
The variables used in this array.
-
#vars ⇒ Array<RDF::Query::Variable>
Return the variables contained within this Array.
Instance Method Details
#aggregate? ⇒ Boolean
144 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 144 def aggregate?; false; end |
#bind(solution) ⇒ self
Binds the pattern to a solution, making it no longer variable if all variables are resolved to bound variables
109 110 111 112 113 114 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 109 def bind(solution) map! do |op| op.respond_to?(:bind) ? op.bind(solution) : op end self end |
#c14nxl(options = {}) ⇒ Object
Canonicalize the NodeSet. Return a new NodeSet marked as being canonical with all child nodes canonicalized.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/extensions.rb', line 136 def c14nxl( = {}) # Create a new NodeSet set = [] set.instance_variable_set(:@c14nxl, true) # Unless passed a set of namespaces, figure them out from namespace_scopes #options[:namespaces] ||= first.parent.namespace_scopes.compact.inject({}) do |memo, ns| # memo[ns.prefix] = ns.href.to_s # memo #end self.each {|c| set << (c.respond_to?(:c14nxl) ? c.c14nxl() : c)} set end |
#constant? ⇒ Boolean
125 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 125 def constant?; !(variable?); end |
#deep_dup ⇒ Object
Deep duplicate
222 223 224 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 222 def deep_dup map(&:deep_dup) end |
#evaluatable? ⇒ Boolean
142 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 142 def evaluatable?; true; end |
#executable? ⇒ Boolean
143 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 143 def executable?; false; end |
#execute(queryable, **options) ⇒ Object
If #execute
is invoked, it implies that a non-implemented Algebra operator
is being invoked
89 90 91 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 89 def execute(queryable, **) raise NotImplementedError, "SPARQL::Algebra '#{first}' operator not implemented" end |
#ndvars ⇒ Array<RDF::Query::Variable>
Return the non-destinguished variables contained within this Array
192 193 194 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 192 def ndvars vars.reject(&:distinguished?) end |
#node? ⇒ Boolean
Does this contain any nodes?
139 140 141 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 139 def node? any?(&:node?) end |
#opt_sort(ordered: false) ⇒ Array
Optionally order items
51 52 53 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/json-ld-f1de87658826/lib/json/ld/extensions.rb', line 51 def opt_sort(ordered: false) ordered ? sort : self end |
#optimize(**options) ⇒ Array
Return an optimized version of this array.
98 99 100 101 102 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 98 def optimize(**) self.map do |op| op.optimize(**) if op.respond_to?(:optimize) end end |
#replace_aggregate! {|agg| ... } ⇒ SPARQL::Algebra::Evaluatable, RDF::Query::Variable
Recursively re-map operators to replace aggregates with temporary variables returned from the block
175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 175 def replace_aggregate!(&block) map! do |op| case when op.respond_to?(:aggregate?) && op.aggregate? yield op when op.respond_to?(:replace_aggregate!) op.replace_aggregate!(&block) else op end end self end |
#replace_vars! {|var| ... } ⇒ SPARQL::Algebra::Evaluatable
Replace operators which are variables with the result of the block descending into operators which are also evaluatable
154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 154 def replace_vars!(&block) map! do |op| case when op.respond_to?(:variable?) && op.variable? yield op when op.respond_to?(:replace_vars!) op.replace_vars!(&block) else op end end self end |
#to_s_with_c14nxl ⇒ Object Also known as: to_s
Serialize a canonicalized Node or NodeSet to XML
Override standard #to_s implementation to output in c14n representation if the Node or NodeSet is marked as having been canonicalized
156 157 158 159 160 161 162 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/extensions.rb', line 156 def to_s_with_c14nxl if instance_variable_defined?(:@c14nxl) map {|c| c.to_s}.join("") else to_s_without_c14nxl end end |
#to_sparql(delimiter: " ", **options) ⇒ String
Returns a partial SPARQL grammar for this array.
75 76 77 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 75 def to_sparql(delimiter: " ", **) map {|e| e.to_sparql(**)}.join(delimiter) end |
#to_sxp ⇒ String
Returns the SXP representation of this object.
165 166 167 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sxp.rb-7a771a32c5fe/lib/sxp/extensions.rb', line 165 def to_sxp() '(' << map { |x| x.to_sxp(**) }.join(' ') << ')' end |
#to_sxp_bin ⇒ String
Returns the SXP representation of this object, defaults to self
.
64 65 66 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 64 def to_sxp_bin map {|x| x.to_sxp_bin} end |
#valid? ⇒ Boolean
Is this value composed only of valid components?
207 208 209 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 207 def valid? all? {|e| e.respond_to?(:valid?) ? e.valid? : true} end |
#validate! ⇒ Array
Validate all components.
215 216 217 218 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 215 def validate! each {|e| e.validate! if e.respond_to?(:validate!)} self end |
#variable? ⇒ Boolean
Returns true
if any of the operands are variables, false
otherwise.
122 123 124 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 122 def variable? any? {|op| op.respond_to?(:variable?) && op.variable?} end |
#variables ⇒ Hash{Symbol => RDF::Query::Variable}
The variables used in this array.
131 132 133 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 131 def variables self.inject({}) {|hash, o| o.respond_to?(:variables) ? hash.merge(o.variables) : hash} end |
#vars ⇒ Array<RDF::Query::Variable>
Return the variables contained within this Array
199 200 201 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sparql-36baa432eb7f/lib/sparql/algebra/extensions.rb', line 199 def vars select {|o| o.respond_to?(:vars)}.map(&:vars).flatten.compact end |