Class: Array

Inherits:
Object show all
Defined in:
vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/json-ld-6d1165d8a4ab/lib/json/ld/extensions.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/sxp.rb-3ed4391fdac1/lib/sxp/writer.rb,
vendor/bundler/ruby/3.0.0/bundler/gems/rdf-xsd-093c0abb125d/lib/rdf/xsd/extensions.rb

Overview

REXML C14N

Direct Known Subclasses

RDF::Query::Solutions, SHACL::Shapes

Instance Method Summary collapse

Instance Method Details

#aggregate?Boolean

Returns:

  • (Boolean)


133
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 133

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

Parameters:

Returns:

  • (self)


106
107
108
109
110
111
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 106

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.

Parameters:



136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/rdf-xsd-093c0abb125d/lib/rdf/xsd/extensions.rb', line 136

def c14nxl(options = {})
  # 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(options) : c)}
  set
end

#constant?Boolean

Returns:

  • (Boolean)


122
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 122

def constant?; !(variable?); end

#deep_dupObject

Deep duplicate



211
212
213
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 211

def deep_dup
  map(&:deep_dup)
end

#evaluatable?Boolean

Returns:

  • (Boolean)


131
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 131

def evaluatable?; true; end

#evaluate(bindings, **options) ⇒ RDF::Term

Evaluates the array using the given variable bindings.

In this case, the Array has two elements, the first of which is an XSD datatype, and the second is the expression to be evaluated. The result is cast as a literal of the appropriate type

Parameters:

Returns:

See Also:



72
73
74
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 72

def evaluate(bindings, **options)
  SPARQL::Algebra::Expression.extension(*self.map {|o| o.evaluate(bindings, **options)})
end

#executable?Boolean

Returns:

  • (Boolean)


132
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 132

def executable?; false; end

#execute(queryable, **options) ⇒ Object

If #execute is invoked, it implies that a non-implemented Algebra operator is being invoked

Parameters:

Raises:

  • (NotImplementedError)

    If an attempt is made to perform an unsupported operation

See Also:



86
87
88
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 86

def execute(queryable, **options)
  raise NotImplementedError, "SPARQL::Algebra '#{first}' operator not implemented"
end

#ndvarsArray<RDF::Query::Variable>

Return the non-destinguished variables contained within this Array



181
182
183
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 181

def ndvars
  vars.reject(&:distinguished?)
end

#node?Boolean

Does this contain any nodes?

Returns:

  • (Boolean)


128
129
130
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 128

def node?
  any?(&:node?)
end

#opt_sort(ordered: false) ⇒ Array

Optionally order items

Parameters:

  • ordered (Boolean) (defaults to: false)

Returns:



50
51
52
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/json-ld-6d1165d8a4ab/lib/json/ld/extensions.rb', line 50

def opt_sort(ordered: false)
  ordered ? self.sort : self
end

#optimize(**options) ⇒ Array

Return an optimized version of this array.

Returns:

  • (Array)

    a copy of self

See Also:



95
96
97
98
99
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 95

def optimize(**options)
  self.map do |op|
    op.optimize(**options) 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

Yields:

  • agg

Yield Parameters:

Yield Returns:

Returns:



164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 164

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

Yields:

  • var

Yield Parameters:

Yield Returns:

Returns:



143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 143

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_c14nxlObject 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.0.0/bundler/gems/rdf-xsd-093c0abb125d/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_sxpString

Returns the SXP representation of this object.

Returns:



124
125
126
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sxp.rb-3ed4391fdac1/lib/sxp/writer.rb', line 124

def to_sxp
  '(' << map { |x| x.to_sxp }.join(' ') << ')'
end

#to_sxp_binString

Returns the SXP representation of this object, defaults to self.

Returns:



55
56
57
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 55

def to_sxp_bin
  map {|x| x.to_sxp_bin}
end

#valid?Boolean

Is this value composed only of valid components?

Returns:

  • (Boolean)

    true or false



196
197
198
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 196

def valid?
  all? {|e| e.respond_to?(:valid?) ? e.valid? : true}
end

#validate!Array

Validate all components.

Returns:

Raises:

  • (ArgumentError)

    if the value is invalid



204
205
206
207
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 204

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.

Returns:

  • (Boolean)

    true or false

See Also:



119
120
121
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 119

def variable?
  any? {|op| op.respond_to?(:variable?) && op.variable?}
end

#varsArray<RDF::Query::Variable>

Return the variables contained within this Array



188
189
190
# File 'vendor/bundler/ruby/3.0.0/bundler/gems/sparql-ffa592c8f275/lib/sparql/algebra/extensions.rb', line 188

def vars
  select {|o| o.respond_to?(:vars)}.map(&:vars).flatten.compact
end