Class: ShEx::Extension
- Extended by:
- Enumerable
- Defined in:
- vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/extensions/extension.rb
Overview
Abstract class of ShEx Extension extensions.
Extensions are registered automatically when they are required by subclassing this class.
Implementations may provide an initializer which is called once for a given semantic action. Additionally, enter
and exit
methods are invoked when beginning any Triple Expression containing this Semantic Action. The visit
method is invoked once for each matched triple within that Triple Expression.
Subclasses must define at least visit
.
Class Method Summary collapse
-
.each {|klass| ... } ⇒ Enumerator
Enumerates known Semantic Action classes.
-
.find(name) ⇒ SemanticAction
Return the SemanticAction associated with a URI.
-
.name ⇒ String
The "name" of this class is a URI used to uniquely identify it.
Instance Method Summary collapse
-
#close(schema: nil, depth: 0, **options) ⇒ self
Called after shape completes on success or failure.
-
#enter(code: nil, arcs_in: nil, arcs_out: nil, expression: nil, depth: 0, **options) ⇒ Boolean
Called on entry to containing TripleExpression.
-
#exit(code: nil, matched: [], unmatched: [], expression: nil, depth: 0, **options) ⇒ self
Called on exit from containing TripleExpression.
-
#initialize(schema: nil, logger: nil, depth: 0, **options) ⇒ self
constructor
Initializer for a given instance.
-
#visit(code: nil, matched: nil, expression: nil, depth: 0, **options) ⇒ Boolean
Called after a TripleExpression has matched zero or more statements.
Constructor Details
#initialize(schema: nil, logger: nil, depth: 0, **options) ⇒ self
Initializer for a given instance. Implementations may define this for instance and/or class
101 102 103 104 105 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/extensions/extension.rb', line 101 def initialize(schema: nil, logger: nil, depth: 0, **) @logger = logger @options = self end |
Class Method Details
.each {|klass| ... } ⇒ Enumerator
Enumerates known Semantic Action classes.
54 55 56 57 58 59 60 61 62 63 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/extensions/extension.rb', line 54 def each(&block) if self.equal?(ShEx::Extension) # This is needed since all Semantic Action classes are defined using # Ruby's autoloading facility, meaning that `@@subclasses` will be # empty until each subclass has been touched or require'd. @@subclasses.values.each(&block) else block.call(self) end end |
.find(name) ⇒ SemanticAction
Return the SemanticAction associated with a URI.
70 71 72 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/extensions/extension.rb', line 70 def find(name) @@subclasses.fetch(name.to_s, nil) end |
.name ⇒ String
The "name" of this class is a URI used to uniquely identify it.
44 45 46 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/extensions/extension.rb', line 44 def name @@subclasses.invert[self] end |
Instance Method Details
#close(schema: nil, depth: 0, **options) ⇒ self
Called after shape completes on success or failure
157 158 159 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/extensions/extension.rb', line 157 def close(schema: nil, depth: 0, **) self end |
#enter(code: nil, arcs_in: nil, arcs_out: nil, expression: nil, depth: 0, **options) ⇒ Boolean
Called on entry to containing TripleExpression
118 119 120 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/extensions/extension.rb', line 118 def enter(code: nil, arcs_in: nil, arcs_out: nil, expression: nil, depth: 0, **) true end |
#exit(code: nil, matched: [], unmatched: [], expression: nil, depth: 0, **options) ⇒ self
Called on exit from containing TripleExpression
147 148 149 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/extensions/extension.rb', line 147 def exit(code: nil, matched: [], unmatched: [], expression: nil, depth: 0, **) self end |
#visit(code: nil, matched: nil, expression: nil, depth: 0, **options) ⇒ Boolean
Called after a TripleExpression has matched zero or more statements
132 133 134 |
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/shex-f64040a493d0/lib/shex/extensions/extension.rb', line 132 def visit(code: nil, matched: nil, expression: nil, depth: 0, **) raise NotImplementedError end |