Class: Dry::Logic::Operations::Implication

Inherits:
Binary show all
Defined in:
lib/dry/logic/operations/implication.rb

Instance Attribute Summary

Attributes inherited from Binary

#left, #right

Attributes inherited from Abstract

#options, #rules

Instance Method Summary collapse

Methods inherited from Binary

#ast, #initialize, #to_s

Methods inherited from Abstract

#curry, #id, #initialize, #new, #to_ast, #with

Methods included from Dry::Logic::Operators

#and, #or, #then, #xor

Constructor Details

This class inherits a constructor from Dry::Logic::Operations::Binary

Instance Method Details

#[](input) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/dry/logic/operations/implication.rb', line 26

def [](input)
  if left[input]
    right[input]
  else
    true
  end
end

#call(input) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/dry/logic/operations/implication.rb', line 15

def call(input)
  left_result = left.(input)

  if left_result.success?
    right_result = right.(input)
    Result.new(right_result.success?, id) { right_result.to_ast }
  else
    Result::SUCCESS
  end
end

#operatorObject



11
12
13
# File 'lib/dry/logic/operations/implication.rb', line 11

def operator
  :then
end

#typeObject



7
8
9
# File 'lib/dry/logic/operations/implication.rb', line 7

def type
  :implication
end