Sha256: e72c7769ca69c6179cdf5ed2b474a8f124ac075c801a36c4b77200bbc7bb4040

Contents?: true

Size: 628 Bytes

Versions: 11

Compression:

Stored size: 628 Bytes

Contents

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

    attr_reader :value
    protected :value

    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.new
      end
    end

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fear-0.10.0 lib/fear/some.rb
fear-0.9.0 lib/fear/some.rb
fear-0.8.0 lib/fear/some.rb
fear-0.7.0 lib/fear/some.rb
fear-0.6.0 lib/fear/some.rb
fear-0.5.0 lib/fear/some.rb
fear-0.4.2 lib/fear/some.rb
fear-0.4.1 lib/fear/some.rb
fear-0.4.0 lib/fear/some.rb
fear-0.3.0 lib/fear/some.rb
fear-0.2.0 lib/fear/some.rb