@@ -17,52 +17,6 @@ class Operator
1717 # Initialization options
1818 attr_accessor :options
1919
20- ##
21- # Returns an operator class for the given operator `name`.
22- #
23- # @param [Symbol, #to_s] name
24- # @param [Integer] arity
25- # @return [Class] an operator class, or `nil` if an operator was not found
26- def self . for ( name , arity = nil )
27- {
28- and : And ,
29- annotation : Annotation ,
30- base : Base ,
31- each_of : EachOf ,
32- inclusion : Inclusion ,
33- nodeConstraint : NodeConstraint ,
34- not : Not ,
35- one_of : OneOf ,
36- or : Or ,
37- prefix : Prefix ,
38- schema : Schema ,
39- semact : SemAct ,
40- external : External ,
41- shape_ref : ShapeRef ,
42- shape : Shape ,
43- start : Start ,
44- stem : Stem ,
45- stemRange : StemRange ,
46- tripleConstraint : TripleConstraint ,
47- value : Value ,
48- } . fetch ( name . to_s . downcase . to_sym )
49- end
50-
51- ##
52- # Returns the arity of this operator class.
53- #
54- # @example
55- # Operator.arity #=> -1
56- # Operator::Nullary.arity #=> 0
57- # Operator::Unary.arity #=> 1
58- # Operator::Binary.arity #=> 2
59- # Operator::Ternary.arity #=> 3
60- #
61- # @return [Integer] an integer in the range `(-1..3)`
62- def self . arity
63- self . const_get ( :ARITY )
64- end
65-
6620 ARITY = -1 # variable arity
6721
6822 ##
@@ -93,9 +47,8 @@ def initialize(*operands)
9347 when TrueClass , FalseClass , Numeric , String , DateTime , Date , Time
9448 RDF ::Literal ( operand )
9549 when NilClass
96- raise ShEx ::OperandError , "Found nil operand for #{ self . class . name } "
97- nil
98- else raise TypeError , "invalid SPARQL::Algebra::Operator operand: #{ operand . inspect } "
50+ raise ArgumentError , "Found nil operand for #{ self . class . name } "
51+ else raise TypeError , "invalid ShEx::Algebra::Operator operand: #{ operand . inspect } "
9952 end
10053 end
10154
@@ -110,67 +63,13 @@ def initialize(*operands)
11063 end
11164 end
11265
113- ##
114- # Base URI used for reading data sources with relative URIs
115- #
116- # @return [RDF::URI]
117- def base_uri
118- Operator . base_uri
119- end
120-
121- ##
122- # Base URI used for reading data sources with relative URIs
123- #
124- # @return [RDF::URI]
125- def self . base_uri
126- @base_uri
127- end
128-
12966 ##
13067 # Is this shape closed?
13168 # @return [Boolean]
13269 def closed?
13370 operands . include? ( :closed )
13471 end
13572
136- ##
137- # Set Base URI associated with SPARQL document, typically done
138- # when reading SPARQL from a URI
139- #
140- # @param [RDF::URI] uri
141- # @return [RDF::URI]
142- def self . base_uri = ( uri )
143- @base_uri = RDF ::URI ( uri )
144- end
145-
146- ##
147- # Prefixes useful for future serialization
148- #
149- # @return [Hash{Symbol => RDF::URI}]
150- # Prefix definitions
151- def prefixes
152- Operator . prefixes
153- end
154-
155- ##
156- # Prefixes useful for future serialization
157- #
158- # @return [Hash{Symbol => RDF::URI}]
159- # Prefix definitions
160- def self . prefixes
161- @prefixes
162- end
163-
164- ##
165- # Prefixes useful for future serialization
166- #
167- # @param [Hash{Symbol => RDF::URI}] hash
168- # Prefix definitions
169- # @return [Hash{Symbol => RDF::URI}]
170- def self . prefixes = ( hash )
171- @prefixes = hash
172- end
173-
17473 ##
17574 # Semantic Actions
17675 # @return [Array<SemAct>]
@@ -344,6 +243,7 @@ class Unary < Operator
344243 # @param [Hash{Symbol => Object}] options
345244 # any additional options (see {Operator#initialize})
346245 def initialize ( arg1 , options = { } )
246+ raise ArgumentError , "wrong number of arguments (given 2, expected 1)" unless options . is_a? ( Hash )
347247 super
348248 end
349249 end # Unary
@@ -365,6 +265,7 @@ class Binary < Operator
365265 # @param [Hash{Symbol => Object}] options
366266 # any additional options (see {Operator#initialize})
367267 def initialize ( arg1 , arg2 , options = { } )
268+ raise ArgumentError , "wrong number of arguments (given 3, expected 2)" unless options . is_a? ( Hash )
368269 super
369270 end
370271 end # Binary
0 commit comments