lib/grumlin/expressions/p.rb in grumlin-0.23.0 vs lib/grumlin/expressions/p.rb in grumlin-1.0.0.rc1
- old
+ new
@@ -1,40 +1,36 @@
# frozen_string_literal: true
-module Grumlin
- module Expressions
- class P
- class Predicate
- attr_reader :namespace, :name, :value, :type
+class Grumlin::Expressions::P
+ class Predicate
+ attr_reader :namespace, :name, :value, :type
- def initialize(namespace, name, value:, type: nil)
- @namespace = namespace
- @name = name
- @value = value
- @type = type
- end
+ def initialize(namespace, name, value:, type: nil)
+ @namespace = namespace
+ @name = name
+ @value = value
+ @type = type
+ end
+ end
+
+ class << self
+ # TODO: support more predicates
+ [:eq, :gt, :lt, :neq].each do |predicate|
+ define_method predicate do |*args|
+ Predicate.new("P", predicate, value: args[0])
end
+ end
- class << self
- # TODO: support more predicates
- %i[eq gt lt neq].each do |predicate|
- define_method predicate do |*args|
- Predicate.new("P", predicate, value: args[0])
- end
- end
-
- %i[within without].each do |predicate|
- define_method predicate do |*args|
- args = if args.count == 1 && args[0].is_a?(Array)
- args[0]
- elsif args.count == 1 && args[0].is_a?(Set)
- args[0].to_a
- else
- args.to_a
- end
- Predicate.new("P", predicate, value: args, type: "List")
- end
- end
+ [:within, :without].each do |predicate|
+ define_method predicate do |*args|
+ args = if args.count == 1 && args[0].is_a?(Array)
+ args[0]
+ elsif args.count == 1 && args[0].is_a?(Set)
+ args[0].to_a
+ else
+ args.to_a
+ end
+ Predicate.new("P", predicate, value: args, type: "List")
end
end
end
end