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