Sha256: 6c733362063471cf06e82fb235288ee907a93e2eb2d893f654edf74fdfc9c051

Contents?: true

Size: 497 Bytes

Versions: 12

Compression:

Stored size: 497 Bytes

Contents

module USaidWat
  class Either
    attr_reader :value

    def initialize(value)
      @value = value
    end

    def >>(&block)
      raise NoMethodError, 'subclasses must define >>'
    end

    def left?
      false
    end

    def right?
      false
    end
  end

  class Left < Either
    def >>(callable)
      self
    end

    def left?
      true
    end
  end

  class Right < Either
    def >>(callable)
      callable.call(self)
    end

    def right?
      true
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
usaidwat-1.6.1 lib/usaidwat/either.rb
usaidwat-1.6.0 lib/usaidwat/either.rb
usaidwat-1.5.1 lib/usaidwat/either.rb
usaidwat-1.5.0 lib/usaidwat/either.rb
usaidwat-1.4.5 lib/usaidwat/either.rb
usaidwat-1.4.4 lib/usaidwat/either.rb
usaidwat-1.4.3 lib/usaidwat/either.rb
usaidwat-1.4.2 lib/usaidwat/either.rb
usaidwat-1.4.1 lib/usaidwat/either.rb
usaidwat-1.4.0 lib/usaidwat/either.rb
usaidwat-1.3.0 lib/usaidwat/either.rb
usaidwat-1.2.0 lib/usaidwat/either.rb