Sha256: 52d8d4f365af19a905d664e9f946e277fe5b7b1018bb7416cb9335ecfd3674cc

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 Bytes

Contents

module Fear
  class Some
    include Option
    include Dry::Equalizer(:get)
    include RightBiased::Right
    include SomePatternMatch.mixin

    attr_reader :value
    protected :value

    # FIXME: nice inspect

    def initialize(value)
      @value = value
    end

    # @return [any]
    def get
      @value
    end

    # @return [any]
    def or_nil
      @value
    end

    # @return [false]
    def empty?
      false
    end

    # @return [Option]
    def select
      if yield(value)
        self
      else
        None
      end
    end

    # @return [Option]
    def reject
      if yield(value)
        None
      else
        self
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fear-0.11.0 lib/fear/some.rb