Class: Remap::Mapper::Xor
- Inherits:
-
Binary
- Object
- Dry::Struct
- Struct
- Remap::Mapper
- Binary
- Remap::Mapper::Xor
- Defined in:
- lib/remap/mapper/xor.rb
Overview
Represents two mappers that are combined with the ^ operator
Instance Method Summary collapse
-
#call!(state) {|if| ... } ⇒ Result
Succeeds if left or right succeeds, but not both.
- #inspect ⇒ String (also: #to_s)
Methods inherited from Binary
Methods included from API
Methods included from Operations
Instance Method Details
#call!(state) {|if| ... } ⇒ Result
Succeeds if left or right succeeds, but not both
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/remap/mapper/xor.rb', line 34 def call!(state, &error) state1 = left.call!(state) do |failure1| return right.call!(state) do |failure2| return error[failure1.merge(failure2)] end end state2 = right.call!(state) do return state1 end state1.combine(state2).failure("Both left and right passed xor operation").then(&error) end |
#inspect ⇒ String Also known as: to_s
49 50 51 |
# File 'lib/remap/mapper/xor.rb', line 49 def inspect "%s ^ %s" % [left, right] end |