Class: ShEx::Algebra::Annotation

Inherits:
Operator
  • Object
show all
Defined in:
lib/shex/algebra/annotation.rb

Constant Summary collapse

NAME =
:annotation

Constants inherited from Operator

Operator::ARITY

Instance Attribute Summary

Attributes inherited from Operator

#id, #logger, #operands, #options, #schema

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Operator

#base_uri, #closed?, #each_descendant, #eql?, #expression, #expressions, #focus, #focus=, #initialize, #inspect, iri, #iri, #json_type, #matched, #matched=, #message, #message=, #not_matched, #not_satisfied, #operand, #parent, #parent=, #satisfied, #satisfied=, #satisfy, #semact?, #semantic_actions, #serialize_value, #status, #structure_error, #to_json, #to_sxp, #to_sxp_bin, #triple_expression?, #unmatched, #unmatched=, #unsatisfied, #unsatisfied=, #validate!, #value, value

Constructor Details

This class inherits a constructor from ShEx::Algebra::Operator

Class Method Details

.from_shexj(operator, options = {}) ⇒ Operator

Creates an operator instance from a parsed ShExJ representation

Returns:

Raises:

  • (ArgumentError)


10
11
12
13
14
15
# File 'lib/shex/algebra/annotation.rb', line 10

def self.from_shexj(operator, options = {})
  raise ArgumentError unless operator.is_a?(Hash) && operator['type'] == "Annotation"
  raise ArgumentError, "missing predicate in #{operator.inspect}" unless operator.has_key?('predicate')
  raise ArgumentError, "missing object in #{operator.inspect}" unless operator.has_key?('object')
  super
end

Instance Method Details

#to_hObject



17
18
19
20
21
22
23
# File 'lib/shex/algebra/annotation.rb', line 17

def to_h
  {
    'type' => json_type,
    'predicate' => operands.first.last.to_s,
    'object' => serialize_value(operands.last)
  }
end