Class: Dry::Logic::Operations::Binary
- Defined in:
- lib/dry/logic/operations/binary.rb
Direct Known Subclasses
And, Implication, Or, Xor
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Attributes inherited from Abstract
Instance Method Summary collapse
- #ast(input = Undefined) ⇒ Object
-
#initialize(left, right, **options) ⇒ Binary
constructor
A new instance of Binary.
- #to_s ⇒ Object
Methods inherited from Abstract
#curry, #id, #new, #to_ast, #with
Methods included from Dry::Logic::Operators
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, **) super @left = left @right = right end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
7 8 9 |
# File 'lib/dry/logic/operations/binary.rb', line 7 def left @left end |
#right ⇒ Object (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_s ⇒ Object
21 22 23 |
# File 'lib/dry/logic/operations/binary.rb', line 21 def to_s "#{left} #{operator.to_s.upcase} #{right}" end |