Sha256: e3888782d048f1291adba070321be32e87dc924b7171d15d7d9b2fd89d937d80

Contents?: true

Size: 864 Bytes

Versions: 1

Compression:

Stored size: 864 Bytes

Contents

module Fear
  class Left
    include Either
    include RightBiased::Left

    # @return [false]
    def right?
      false
    end
    alias success? right?

    # @return [true]
    def left?
      true
    end
    alias failure? left?

    # @param default [Proc, any]
    # @return [Either]
    def select_or_else(default)
      Left.new(Utils.return_or_call_proc(default))
    end

    # @return [Left]
    def select
      self
    end

    # @return [Right] value in `Right`
    def swap
      Right.new(value)
    end

    # @param reduce_left [Proc]
    # @return [any]
    def reduce(reduce_left, _)
      reduce_left.call(value)
    end

    # @return [self]
    def join_right
      self
    end

    # @return [Either]
    # @raise [TypeError]
    def join_left
      value.tap do |v|
        Utils.assert_type!(v, Either)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fear-0.2.0 lib/fear/left.rb