Class: Dry::Logic::Operations::Binary

Inherits:
Abstract
  • Object
show all
Defined in:
lib/dry/logic/operations/binary.rb

Direct Known Subclasses

And, Implication, Or, Xor

Instance Attribute Summary collapse

Attributes inherited from Abstract

#options, #rules

Instance Method Summary collapse

Methods inherited from Abstract

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

Methods included from Dry::Logic::Operators

#and, #or, #then, #xor

Constructor Details

#initialize(left, right, **options) ⇒ Binary

Returns a new instance of Binary.



11
12
13
14
15
# File 'lib/dry/logic/operations/binary.rb', line 11

def initialize(left, right, **options)
  super
  @left = left
  @right = right
end

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



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

def left
  @left
end

#rightObject (readonly)

Returns the value of attribute right.



9
10
11
# File 'lib/dry/logic/operations/binary.rb', line 9

def right
  @right
end

Instance Method Details

#ast(input = Undefined) ⇒ Object



17
18
19
# File 'lib/dry/logic/operations/binary.rb', line 17

def ast(input = Undefined)
  [type, [left.ast(input), right.ast(input)]]
end

#to_sObject



21
22
23
# File 'lib/dry/logic/operations/binary.rb', line 21

def to_s
  "#{left} #{operator.to_s.upcase} #{right}"
end