lib/logicality/logic.rb in logicality-1.0.4 vs lib/logicality/logic.rb in logicality-1.0.5
- old
+ new
@@ -1,16 +1,18 @@
+# frozen_string_literal: true
+
#
# Copyright (c) 2018-present, Blue Marble Payroll, LLC
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
module Logicality
+ # Class that defines the main class-level API for this library.
class Logic
class << self
-
def evaluate(expression, input = nil, resolver = nil)
node = get(expression)
wrapper = resolver_wrapper(input, resolver)
interpreter = Interpreter::SimpleInterpreter.new(wrapper)
@@ -19,13 +21,13 @@
private
def resolver_wrapper(input, resolver)
if resolver
- lambda { |value| resolver.call(value, input) }
+ ->(value) { resolver.call(value, input) }
else
- lambda { |value| object_resolver.call(value, input) }
+ ->(value) { object_resolver.call(value, input) }
end
end
def object_resolver
lambda do |value, input|
@@ -57,9 +59,8 @@
lexer = Lexer::RegexpLexer.new(expression)
parser = Parser::SimpleParser.new(lexer)
set(expression, parser.parse)
end
-
end
end
end