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(*rules, **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(*rules, **options) ⇒ Binary
Returns a new instance of Binary.
13 14 15 16 |
# File 'lib/dry/logic/operations/binary.rb', line 13 def initialize(*rules, **) super @left, @right = rules end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
9 10 11 |
# File 'lib/dry/logic/operations/binary.rb', line 9 def left @left end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
11 12 13 |
# File 'lib/dry/logic/operations/binary.rb', line 11 def right @right end |
Instance Method Details
#ast(input = Undefined) ⇒ Object
18 19 20 |
# File 'lib/dry/logic/operations/binary.rb', line 18 def ast(input = Undefined) [type, [left.ast(input), right.ast(input)]] end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/dry/logic/operations/binary.rb', line 22 def to_s "#{left} #{operator.to_s.upcase} #{right}" end |