Sha256: abc5d58dcf20113aa94e43f4b9f16117775a942dcc92eaa85de93072dcc567af

Contents?: true

Size: 387 Bytes

Versions: 3

Compression:

Stored size: 387 Bytes

Contents

module Option
  include Option::Enumerable

  def match(&block)
    Match.new.tap { |m| block.call(m) }.evaluate(self)
  end

  protected

  def and_option(option)
    none? ? self : Some[*[option.value, value].flatten]
  end

  private

  def from_array(values)
    values.empty? ? None : Some[values.first]
  end

  def from_value(value)
    value.nil? ? None : Some[value]
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
optional-0.0.3 lib/optional/option.rb
optional-0.0.2 lib/optional/option.rb
optional-0.0.1 lib/optional/option.rb